title: ArrayList.toArray() method in Java
body: <p>I am wondering why did they design the <code>toArray</code> method in <code>ArrayList</code> to take a input of an array in Java?</p>
  
  <pre><code>    ArrayList&lt;String&gt; listArray = new ArrayList&lt;String&gt;();
  
      listArray.add("Germany");
      listArray.add("Holland");
      listArray.add("Sweden");
  
      String []strArray = new String[3];
      String[] a = (String [])listArray.toArray(strArray);
  </code></pre>
  
  <p>To me it appears that, they dont need this input because the instance of the ArrayList itself has enough details to convert the data into an array.</p>
  
  <p>My question is why do they still need the array to be passed in? Thanks.</p>