I have this method that adds two 2d boolean arrays together. So for a given cell, if any array is true for that cell, the cell in the resulting array is set to true.
private boolean[][] addBooleanArrays(List<boolean[][]> arrays) {
boolean[][] result = new boolean[8][8];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
for (boolean[][] b : arrays) {
if (b[i][j] == true) {
result[i][j] = true;
}
}
}
}
return result;
}
I'm feeding this method 16 boolean arrays that I know contain true and false values but I am getting a null pointer exception at the if statement. I can't see why though, maybe I'm missing something. Any help appreciated.