You need that if
block to be inside the inner for
loop, or the indexes don't match to anything in the array.
Currently, that if
statement runs when j
has already reached nCol
, which means it has exceeded the bounds of the array.
To fix this, remove the }
from the line below the comments, and add a }
right at the end. This effectively moves the if
block up into the inner loop.
Update
You might get a null pointer exception calling equals
on references in the array that have not been assigned an object. You should probably change the if
condition to say this.
if(tableData[i][j] != null && tableData[i][j].equals(true)){