I have a very simple question but i can\'t figure out why I\'m having this exception. I\'m trying to create a 2-dimensional Array of objects for a sudoku puzzle, but when I\'m i
grid = new Cell[lines][lines];
creates an array of size [0][0]
because lines
is still 0
when that statement is run.
Whavetever changes you make to lines
later on won't affect the array size, which will remain [0][0]
...
Simpler example:
int size = 0;
Object[] array = new Object[size];
size = 1;
System.out.println(array.length); //prints 0, not 1