Skip to main content
added 8 characters in body
Source Link
Sergey Kalinichenko
  • 729.1k
  • 85
  • 1.2k
  • 1.6k

I noticed that in Java, hashCodehashCode for HashMapHashMap that only contain entries where key and values are same, eg {1:1}{1:1}, {"abc":"abc"}{"abc":"abc"} etc. is always zero. Is there any reasoning behind this odd behavior?

I noticed that in Java, hashCode for HashMap that only contain entries where key and values are same, eg {1:1}, {"abc":"abc"} etc. is always zero. Is there any reasoning behind this odd behavior?

I noticed that in Java, hashCode for HashMap that only contain entries where key and values are same, eg {1:1}, {"abc":"abc"} etc. is always zero. Is there any reasoning behind this odd behavior?

Source Link

Why is HashCode zero for HashMap containing values that are same as keys

I noticed that in Java, hashCode for HashMap that only contain entries where key and values are same, eg {1:1}, {"abc":"abc"} etc. is always zero. Is there any reasoning behind this odd behavior?