Companion code for the ankurm.com post "Top 40 Java Collections Interview Questions (HashMap Internals to Fail-Fast Iterators)". Verified against JDK 25's own HashMap source (TREEIFY_THRESHOLD=8, UNTREEIFY_THRESHOLD=6, MIN_TREEIFY_CAPACITY=64), with every claim backed by a committed docs/output/*.txt transcript from a real run. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YXCrLgRKFgCh9RHKW8xaqJ
10 lines
503 B
Plaintext
10 lines
503 B
Plaintext
equals() overridden without hashCode(): a == b is true, but hashCode() differs
|
|
==============================================================================
|
|
|
|
a.equals(b) = true
|
|
a.hashCode() = 1390869998
|
|
b.hashCode() = 1820383114
|
|
(these should be IDENTICAL per the contract - they are not, because hashCode() was never overridden)
|
|
|
|
HashSet<EqualsOnlyPoint> after adding two equal-but-differently-hashed points: size=2
|
|
HashSet<CorrectPoint> after adding two equal, correctly-hashed points: size=1 |