ProLesson 7.5Advanced5 min readUpdated 30 October 2026
How HashMap works inside
Buckets, hashing, collisions, resizing and treeification, explained step by step. One of the most asked Java interview questions.
"How does HashMap work internally?" is probably the single most asked Java interview question. Let's build the picture step by step, so you can explain it confidently on a whiteboard.
01Step 1: an array of buckets
Inside, a HashMap is an array called the table. Each slot is a bucket. The default table has 16 buckets.
text
table[0] → (empty)
table[7] → [ "book"=3 ] → [ "ink"=5 ] ← two keys in one bucket (a collision)
table[8] → [ "pen"=40 ]
table[9] → [ "bag"=10 ]
...Each entry (a Node) stores the key, the value, the key's hash, and a link to the next node in the same bucket.
Loading the rest of the lesson…