Using a 2D Array in a Class Object - NullPointerException?

you have already declared the two variables …

so now all you need to do is allocate them in the constructor.

aWallR = new boolean[nCell][nCell];
aWallD = new boolean[nCell][nCell]; 

as is you are declaring them twice, the compiler won’t allow that.

1 Like