I just read in Effective Java that the fifth principle of the equals() method is that all objects must be unequal with null . The book further states that some classes written by programmers protect this using an explicit test for null :
public boolean equals(Object o){ if (o == null) return false; ... }
According to efficient Java, the above non-zero test is not needed. However, my question is, why then do many programmers test this non-nullity requirement?
blackpanther
source share