Reputation: 3
I've got a type Package
, and I want to make something like a rubic's cube. I want to make the floor with a 2-dimensional array and each entry will hold a list (3D).
Making my 2D array
Package[][] floor = new Package[x][y];
And I've got my List of package, and want to make something like this
floor[i][j]= (new ArrayList <Package>()); in a loop
Can someone explain why I've got the error message:
"Cannot convert Package to ArrayList Package"
On my lessons teacher said, I can do something like this.
Upvotes: 0
Views: 61
Reputation: 400
Your array is declared to store Package
type objects.
I assume that you want to store Lists
of Package
objects in that array.
I found answer on Stack which tells that you cannot create arrays of parameterized objects. It means that you are unable to create array of lists.
Guy who answered thst question shows example of how to create ArrayList
of ArrayLists
. Using that example you should be able to create what you want.
You have to create 2D ArrayList
of Lists
.
Upvotes: 1