Under the Hood / Part 1YOUTUBE PLAYER LOADS ON PLAYJava HashMap Explained Visually
HashMap
Java HashMap Explained Visually: hashCode, Buckets, put and get | Part 1
In this lesson
How does a HashMap find your value without searching? Watch it happen, step by step.
→ Inside, a HashMap is an array of 16 buckets → put: hashCode() turns the key into a number, the number picks a bucket, the pair is stored there → get: same key, same hash code, same bucket, then equals() confirms the key → Why it's O(1) on average: one calculation and one jump, not a search → Putting the same key again replaces the value (and put returns the old one) → The twist: "kiwi" and "pear" land in the same bucket. That's a collision, coming in part 2.
All the numbers on screen are real: "apple".hashCode() really is 93029210.
Under the Hood: how Java really works. Part 2: collisions, trees and resizing.
Instagram: @thecodestormdev
Under the Hood, 7 out
1Java HashMap Explained Visually: hashCode, Buckets, put and get | Part 11:302Java HashMap Collisions, Treeify and Resize Explained Visually | Part 21:393The equals and hashCode Contract in Java HashMap, Explained Visually | Part 31:354JDK vs JRE vs JVM: How Java Really Runs Your Code1:335Stack vs Heap in Java: Where Your Variables Actually Live1:436Java Is Always Pass-by-Value (Even for Objects)1:297Why == Fails on Strings in Java (The String Pool)1:158The Integer cache: why 127 == 127 but 128 != 128Wed 25 NovKeep going
