Skip to main content

Collection.toArray() with generics

1 reply [Last post]
denisw
Offline
Joined: 2005-01-03

Why does the collection toArray() method return a simple Object array and not a array of the paramterized type?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mthornton
Offline
Joined: 2003-06-10

One of the unfortunate consequences of implementing generics using erasure. At runtime the class doesn't know what type of array to create.