So I naively wrote an abstract class (A game board) containing a field with no access modifier for an array used to store the game state (a Square[]). This class has various methods implemented using this Square[]. I also have two subclasses both inheriting from this class, using these same methods from their parent class. 

Now, for one reason or another, I have to make my Square[] private. I thought a simple fix would be to make a getter method as usual, 

```
Class Board {
...
    /**An array contain all the Squares for my board. */
    private Square[] squares;

    public Square[] getSquares() {
        return squares;
    }
}

class MutableBoard extends Board {

    /** An N x N board in initial configuration. */
    MutableBoard(int N) {
        _N = N;
        squares = new Square[_N * _N];
        for (int i = 0; i < squares.length; i++) {
            squares[i] = new Square();
        }
    }

    @Override
    void copy(Board board) {
        _N = board.size();
        _moves = board.numMoves();
        squares = new Square[board.getSquares().length]; //Errors here when used
        for (int i = 0; i < squares.length; i++) {
            squares[i] = board.squares[i].clone();
        }
    }
}

class ConstantBoard extends Board {

    /** A new ConstantBoard that allows a read-only view of BOARD. */
    ConstantBoard(Board board) {
        _board = board;
        squares = board.getSquares();
    }
}

```

but I keep getting null pointer exceptions every time I try to access or modify my array in my subclasses using inherited methods. I think because my Square[] is defined in my parent class, its trying to access Board's copy of the array, not the subclasses copy. Does anyone know an easy fix to this that doesn't involve just putting all my methods in both subclasses (and defeating the whole point of inheritance)?

For example, in my copy method, I want to be able to pass in both a MutableBoard, and Constant Board, but I think its trying to access a copy of Board's squares somehow, which isn't even initialized.