I can't for the life of me figure out what is going on with my code. I know how to set an element in a 2 dimensional arraylist, by doing this :
gridMap.get(0).set(5, 1);
This would set the 6th element in the first inner array to the element 1. (At least this is what it is supposed to do.)
However, when I test the code by running this :
for (int i = 0; i < gridMap.size(); ++i) {
for (int y = 0; y < gridMap.size(); ++y) {
System.out.print(gridMap.get(i).get(y));
}
System.out.println();
}
I get :
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
0000010000
when it's supposed to be this :
0000010000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
What am I doing wrong? I've searched other threads on how to set an element and they all say the code I have above is the way to do it.