What's the reason I can't create generic array types in Java?

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-28T07:47:50Z Indexed on 2010/05/28 7:51 UTC
Read the original article Hit count: 198

Filed under:
|

What's the reason Java doesn't allow us to do

private T[] elements = new T[initialCapacity];

?

I could understand .NET didn't allow us to do that, as in .NET you have value types that at run-time can have different sizes, but in Java all kinds of T will be object references, thus having the same size(correct me if I'm wrong).

What is the reason?

© Stack Overflow or respective owner

Related posts about java

Related posts about generics