What issues should be considered when overriding equals and hashCode in Java?
261513-May-2015
What issues / pitfalls must be considered when overriding equals and hashCode?
Home / DeveloperSection / Forums / What issues should be considered when overriding equals and hashCode in Java?
Anonymous User
14-May-2015Also remember:
When using a hash-based Collection or Map such as HashSet, LinkedHashSet, HashMap, Hashtable, or WeakHashMap, make sure that the hashCode() of the key objects that you put into the collection never changes while the object is in the collection. The bulletproof way to ensure this is to make your keys immutable, which has also other benefits.