The toArray
method (lets pick the implementation in java.util.ArrayList) is the following:
class ArrayList ....{
public T
The point of the
is if the array desired is of a base class of E
. For example if E
is HashMap
but the desired array was Map[]
. If toArray
were locked down to E
this would not be possible.
This type of thing is not needed in generic collections / types due to type-erasure. But there is no type-erasure with arrays so the type of the array can be very important.