I noticed that in Java hashCodefor HashMap, which contains only entries, where the key and values are the same, for example {1:1}, {"abc":"abc"}etc. always equal zero. Are there any arguments for this strange behavior?
hashCode
HashMap
{1:1}
{"abc":"abc"}
This is a consequence of the specification hashCode() for Map.Entrywhat requires the hash codes of keys and values to be xor'd.
hashCode()
Map.Entry
, , - , - , , , Java , () -.