This might be a weird question but...
How can I use a List/ArrayList as type for a 2D Array?
In case I didn't explain myself properly:
int[][] arrayName = new int[9][9];
In this example I want to use ArrayList<int>
instead of just int
, but I'm not allowed to. Either that, or I'm probably using the wrong syntax.
Edit: Looks like I wasn't clear enough with my question (and wrote a misleading title, my bad, fixing it now).
What I have is a grid made with a 2D array like the example above, but I want an ArrayList of Integers as elements of the single cells of this grid.
ArrayList<Integer>[][] grid = new ArrayList<Integer>()[9][9]
Something like this. Is this the correct syntax? Am I even allowed to do it?