It’s because the contract for the equals
method, as specified in the Javadoc for the Object.equals method , explicitly states:
For any non-null reference value x, x.equals(null) should return false.
If the method threw a NullPointerException, it would be non-compliant with the contract.
solved Why doesn’t equals throw NullPointerException when one of the variables is pointing to null [duplicate]