Generic arrays of parametrized ArrayLists in java?

Posted by athena123 on Stack Overflow See other posts from Stack Overflow or by athena123
Published on 2010-03-21T18:30:37Z Indexed on 2010/03/21 18:41 UTC
Read the original article Hit count: 124

Filed under:
|

I am new to Java, so I am not aware of the nitty gritties.
Why can't I create generic array of parametrized ArrayList?
Instead I have to write,

ArrayList<String>[] alist = new ArrayList[10]; 

or I have to create List of ArrayLists.
Aren't arrays supposed to be more efficient than ArrayLists? Then why doesn't Java allow it?
Also, what is the difference between following two lines.

ArrayList<String>[] alist = new ArrayList[10];  
ArrayList<String>[] alist = new ArrayList<?>[10];  

© Stack Overflow or respective owner

Related posts about java

Related posts about discussion