I assume you're talking about a Collection (Set or List).
The no-args version returns an array of Object references (which is how elements are stored in collections anyway). So to use something in this array, you will probably need to downcast the reference back to its original type.
The overridden version uses generics to return an array of the specified type. This automatically downcasts the Object references so that they can be immediately used without explicit downcasting.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Hi Marc, you said the overloaded version ,toArray(Object ) when used so ,automatically downcasted, no explicit casting required. But i tried a program and it show error with expplicit casting ,and even i read it from some web link ,that Still Explicit casting is required s compiler doesnt know about method's argument.
I couldnt understand the need and use of 2nd version of toArray(). The output is same,Ofcourse.