It's just an optimization: comparing two integers is faster than calling equals()
.
If the two hashcodes differ, then, based on the contract of equals
and hashCode
, the map knows that the existing key isn't equal to the given key, and can go faster to the next one.