title: Need for new String[0] in the Set toArray() method
body: <p>I am trying to convert a Set to an Array.</p>
  
  <pre><code>Set&lt;String&gt; s = new HashSet&lt;String&gt;(Arrays.asList("mango","guava","apple"));
  String[] a = s.toArray(new String[0]);
  for(String x:a)
        System.out.println(x);
  </code></pre>
  
  <p>And it works fine. But I don't understand the significance of <code>new String[0]</code> in <code>String[] a = s.toArray(new String[0]);</code>.</p>
  
  <p>I mean initially I was trying <code>String[] a = c.toArray();</code>, but it wan't working. Why is the need for <code>new String[0]</code>. </p>