Cannot create an array of LinkedLists in Java…?

For some reason you have to cast the type and make the declaration like this:

myMatrix = (LinkedList<IntegerNode>[]) new LinkedList<?>[numRows];

Leave a Comment