This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
There's nothing too fancy going on with the toArray() method; it comes in two flavors: one that returns a new Object array, and one that uses the array you send it as the destination array:
David A. Scott
Joined: Apr 13, 2006
From the link supplied by Owen Wise :-
"toArray() without parameter will always return an array of type Object that you won't be able to cast. The toArray(new String) will return an array of type Object that you may cast to String."
I think that's my question answered in the first paragraph. The cast is still required.
Joined: Feb 07, 2005
It depends on whether you use a parametrized collection or not.
If you specify the type to be held in the Collection, then, using the toArray method with the appropriate parameter, you can cast to the original type of array, but it's not necessary.