Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot create a generic array of ArrayList<Integer>

807589Oct 3 2008 — edited Oct 3 2008
Thats probably a simple question but I cant figure out the answer to it. If I try intitialize an array of Lists as
List<Integer>[] a = new ArrayList<Integer>[m]
the compliler shows an error "Cannot create a generic array of ArrayList<Integer>" If I write it as
List<Integer>[] a = new ArrayList[m]
then there is obviously a warning "The expression of type ArrayList[] needs unchecked conversion to conform to List<Integer>[]". Not that i am going to die from extra warnings but still I am curious how do I initialize an array of Lists correctly
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2008
Added on Oct 3 2008
5 comments
6,093 views