I imagine that this line:
for(int row =0; column<board.length;row++)
should be:
for(int row = 0; row < board.length; row++)
Your terminating condition was checking that column
is lesser than board.length
, when it should be checking that row
is lesser than board.length
. You keep incrementing row
, but the termination condition is never true, so you end up going outside the bounds of the array.
Another thing is that your code implicitly assumes that you are working with a square matrix (i.e 2-d array same number of rows and columns). So if you have unequal rows and columns, you will run into the same issue. If your assumption is valid, then this is fine. I imagine this is some kind of game board that is supposed to be square.