Influence of HashMap optimization that caches the hash code associated with each entry to its get method
问题 from p.46 "Effective Java" Joshua Bloch. Item 9: ALways override hashCode when you override equals Some class PhoneNumber overrides equals() and doesn't override hashCode() "two instances are involved: one is used for insertion into the HashMap, and a second, equal, instance is used for (attempted) retrieval." ... "... Even if the two instances happen to hash to the same bucket, the get method will almost certainly return null , as HashMap has an optimization that caches the hash code