Why doesn't Java allow for the creaton of generic arrays?

Posted by byte on Stack Overflow See other posts from Stack Overflow or by byte
Published on 2010-06-07T20:13:39Z Indexed on 2010/06/07 20:22 UTC
Read the original article Hit count: 185

Filed under:
|
|

There are plenty of questions on stackoverflow from people who have attempted to create an array of generics like so:

ArrayList<Foo>[] poo = new ArrayList<Foo>[5];

And the answer of course is that the Java specification doesn't allow you to declare an array of generics.

My question however is why ? What is the technical reason underlying this restriction in the java language or java vm? It's a technical curiosity I've always wondered about.

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays