String[] a = c.toArray(new String[0])# Java - 爪哇娇娃
y*o
1 楼
At the very bottom of the following page:
http://java.sun.com/docs/books/tutorial/collections/interfaces/collection.ht
ml
Suppose that c is known to contain only strings (perhaps because c is of typ
e Collection). The following snippet dumps the contents of c into a
newly allocated array of String whose length is identical to the number of e
lements in c.
String[] a = c.toArray(new String[0]);
The API doc for public T[] toArray(T[] a) says:
http://java.sun.com/docs/books/tutorial/collections/interfaces/collection.ht
ml
Suppose that c is known to contain only strings (perhaps because c is of typ
e Collection
newly allocated array of String whose length is identical to the number of e
lements in c.
String[] a = c.toArray(new String[0]);
The API doc for public