As a side note, when we override equals(), it is recommended to also override the hashCode() method . If we don’t do so, equal objects may get different hash-values; and hash based collections, including HashMap, HashSet, and Hashtable do not work properly (see this for more details).29 Tem 2021
Read moreHow do you correctly override the hashCode () and equals () methods in Java?
if you override equals, you must override hashCode. hashCode must generate equal values for equal objects. equals and hashCode must depend on the same set of significant fields . You must use the same set of fields in both of these methods .31 Ara 2021
Read more