I have written a simple equals() method for a class:
@Override
public boolean equals(Object obj) {
if(obj instanceof Cl) {
Cl u = (Cl)obj;
return u.i == i;
} else {
return false;
}
}
As I know, if I want compare if the class object equals to a null object, this returns false because of the instanceof, but according to my uni teacher this is a bad implementation, as the null check is missing. Can someone confirm for me if my theory is correct or not?