You can assume that I’m modifying a field of the object after I add the object to the HashMap.
That right there is why.
Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map.
“Not specified” means “may not to work”, so you should not be surprised when it doesn’t work.
solved Why doesn’t my hashmap work? My object has the property that hashCode() equality implies equals(…) equality [closed]