title: why does List<String>.toArray() return Object[] and not String[]? how to work around this?
body: <p>Does anybody know why Java 1.6 has this behaviour:</p>
  
  <pre><code>List&lt;String&gt; list = ArrayList&lt;String&gt;();
  String[] arr = (String[]) list.toArray();
  </code></pre>
  
  <p>And I get a ClassCastException, because it returns Object[] and not String[].  </p>
  
  <p>I thought 
  <code>List&lt;T&gt;.toArray()</code> should return T[] - no?  Does anyone have an answer why this inconvenience exists in the language? 
  And also how to work around this? How do I get a String[] from <code>List&lt;String&gt;</code> without looping thru the items?</p>