Back to course home
0% completed
Vote For New Content
Null Pointer Exceptions
E H
Oct 8, 2024
- The Knight and King classes both have the following code to see if the end box has a Piece of the same colour as the King. If the Box is empty however, wouldn't getPiece return null, and in return throw an error when isWhite is called on it?
if (end.getPiece().isWhite() == this.isWhite()) { return false; }
- The boxes matrix is never initialized in the Board class, so "resetting" the board in the constructor will cause a null pointer exception.
0
0
Comments
Comments