Different fields for equals and hashcode
I agree with the statement from this post What issues should be considered when overriding equals and hashCode in Java? Use the same set of fields that you use to compute equals() to compute hashCode(). But i've some doubts : Is this absolutely necessary to have same fields ? If yes, what if I don't use same field ? Will it affect HashMap performance or HashMap Accuracy ? The fields don't have to be the same. The requirement is for two objects that are equal, they must have the same hash code. If they have the same hash code, they don't have to be equal. From the javadocs: Whenever it is