Java Map

Java Map: HashMap vs LinkedHashMap vs TreeMap and More

A Java Map stores unique keys with one value each. Quick put/get/merge/computeIfAbsent examples, a comparison of HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap, EnumMap, Hashtable and Map.of(), and all our Map tutorials grouped by topic.

Design a Good Key for HashMap in Java: Rules and Examples

A good HashMap key overrides equals() and hashCode() together, uses fields that never change and spreads its hash codes well. Records, a mutable key that gets lost, collisions, Comparable keys, EnumMap and Lombok, with tested Java 25 code.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.