java- equals Object ; x y true , x y (x == y true).
public boolean equals(Object obj) {
return (this == obj);
equals () for an object compares references. That is why this is not true, since they are different Objects. equals (), designed to use the internal state of objects for comparison.
To solve your problem, the equals method must be redefined inside the Employee class.
source
share