I have a hash-based collection of objects, such as HashSet or HashMap. What issues can I run into when the implementation of hashCode()
HashSet
HashMap
hashCode()
Don’t change hashcode of elements in hash based collection after put.
Many programmers fall into the pitfall. You could think hashcode is kind of address in collection, so you couldn’t change address of an element after it’s put in the collection.