Need Assistance?

support@tutorialshub.in

Java Collections Framework

HashMap, LinkedHashMap & TreeMap

ADVERTISEMENT
Java Free Lesson
5 min read
ADVERTISEMENT

HashMap stores key-value pairs using hashing (O(1) average get/put). Since Java 8, when a hash bucket has more than 8 collisions, it converts from a linked list to a balanced Red-Black Tree for O(log n) worst-case performance.

Important: If you use a custom class as a HashMap key, always override both equals() and hashCode()!

ADVERTISEMENT
Hi, I'm Tuby! Here to help you