While you can cast the objects in the array to String, you can't cast the Object array to an String array. This can get pretty inconvenient sometimes.
IMHO, the correct solution would have been to return an Object array that can be casted to a common base class array. But they didn't do that. Instead, they provided an overloaded toArray() method that takes an Object array.
This version of toArray() will take an Object array, but that Object array may be a String or any subtype of the Object array. It will then return an Object array which may be casted to the original type of array which was originally passed to the method.... So if you know all the items in the collection are Strings, you can pass it a String array, and cast the returned Object array to a String array.
<T> T toArray(T a)
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.
If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.
Here toArray() method will populate strResult array with the Collection element.
[ August 10, 2006: Message edited by: Naseem Khan ]