This API documentation:
http://java.sun.com/products/jdk/1.2/docs/api/java/util/Collection.html#toArray(java.lang.Object[])
contains this text and code:
Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of
String:
String[] x = (String[]) v.toArray(new String[0]);
Note that the List is called l in the prose and v in the code. The variable names should match.
http://java.sun.com/products/jdk/1.2/docs/api/java/util/Collection.html#toArray(java.lang.Object[])
contains this text and code:
Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of
String:
String[] x = (String[]) v.toArray(new String[0]);
Note that the List is called l in the prose and v in the code. The variable names should match.
- duplicates
-
JDK-4838705 (coll spec) Bug in "toArray" example for Interface "Collection"
-
- Resolved
-