Can't initialize 2D array of objects in Java
Can’t initialize 2D array of objects in Java
I’m trying to make a battleship game, for which I need a 2D array of squares, which are the places that a person can pick. When I run my program however, I get a null pointer exception when I try to call the resetBoard() function.
Battleship class:
public class Battleship { private Square[][] squares; private boolean aircraftCarrierSunk; private boolean battleshipSunk; private boolean…
View On WordPress











