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
The problem is that the default value for an int
is 0.
So when you create your Sudoku
object, grid = new Cell[lines][lines];
is equivalent to grid = new Cell[0][0];
Either change your makeGrid
method or provide a size in your constructor.
public void makeGrid(int size) {
this.lines = size;
grid = new Cell[size][size];
for(int i=0;i