Interactive JVM simulator · not a blog
Watch hashCode() fill the buckets.
Pick a hash function, press Play, and watch objects get hashed and dropped into HashMap buckets in real time — including the moment a bucket turns into a red-black tree.
HashMap<String, User> · capacity 8(n-1) & (h ^ h>>>16)
#0
#1
#2
#3
#4
#5
#6
#7
Faithful hashing
Real String.hashCode() and Objects.hash(), the h ^ (h >>> 16) spread and (n-1) & hash indexing — in 32-bit integer math.
See distribution
Compare a good hash against return 1. One spreads evenly; the other collapses every key into a single bucket.
Watch treeification
At 8 collisions (capacity ≥ 64) a bucket's linked list becomes a red-black tree — rendered node by node.