Suppose x is a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array of String:
String y = x.toArray(new String);
Note that toArray(new Object) is identical in function to toArray().
Recommended and faster to use the zero-size-array format
- links to