Best Practice: Don't use equals(null)
Overview
Sometimes it is not clear when to use == or equals() however one situation where equals is never useful is with null.Don't use equals(null)
From SerialRefif(!object.equals(null)) {The only class object can be is a SerialRef which doesn't implement equals() so a == comparison happens to be used. However this is not clear and a different implementation could be used which doesn't do this.
A better alternative would be
if(object != null) {which is probably what was intended.
Comments
Post a Comment