equals method compares object reference by default (as implemented by Object class)
Override equals if you want to compare based on certain class specific attributes
public boolean equals(Object o) {
//check instanceof before doing anything
if (o instanceof Foo) {
Foo t = (Foo)o;
if (this.empno == t.getEmpno()) {
return true;
}
}
return false;
}