Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of a Java HashMap with a null key stored in bucket zero and multiple null values, highlighting the ambiguity between missing keys and null values.
Java

Java HashMap Null Values: Behavior and Usage

HashMap in Java allows one null key and many null values. See how to use null values safely, why get() can be ambiguous, and when containsKey() is required.

HashMapnull handlingJava collectionsnull key
Illustration of a Java HashMap with a null key represented as an empty slot in the first bucket, showing how the map stores the null key separately.
Java

Java HashMap Null Key: Behavior and Usage

Java HashMap permits one null key. See how put, get, containsKey, and remove treat null keys, which Map implementations reject them, and when null keys should be avoided.

JavaHashMapNull KeyCollections
Illustration of a Java HashMap replacing an existing value when a duplicate key is inserted, showing the old value being returned.
Java

How Java HashMap Handles Duplicate Keys

java hashmap duplicate keys: Learn how Java HashMap handles duplicate keys: replacement behavior, putIfAbsent, multi-value maps, custom key equals/hashCode, and concur...

HashMapJava CollectionsMap APIputIfAbsent
Illustration of iterating over a Java HashMap showing key-value pairs and iteration methods.
Java

Java HashMap Iteration: Methods and Tradeoffs

Learn practical ways to iterate over a Java HashMap with entrySet, keySet, values, forEach, and streams, plus the performance and concurrency tradeoffs to consider.

HashMapJava CollectionsIterationforEach
Illustration of Java HashMap entrySet iteration showing key-value pairs being accessed
Java

Java HashMap entrySet: Iterate Efficiently

Learn how to iterate over a Java HashMap with entrySet(). This guide covers for-each loops, safe removal with iterators, performance trade-offs, and common pitfalls.

JavaHashMapentrySetIteration
Illustration of a Java HashMap showing key-value pairs and the values collection view.
Java

Java HashMap Values: How to Retrieve and Iterate

Retrieve, iterate, and update values in a Java HashMap, with null handling, performance tradeoffs, and safe iteration patterns.

HashMapJava CollectionsIterationNull Handling
A Java HashMap with a keySet view showing keys extracted from the map, illustrating the relationship between the map and its key set.
Java

Java HashMap keySet: Iteration, Behavior, and Pitfalls

How HashMap.keySet() works: a live Set view of keys, safe iteration patterns, and performance and concurrency implications.

javahashmapkeysetiteration
Diagram showing Java HashMap iteration with forEach method over entries, keys, and values.
Java

Java HashMap forEach: Iterate Entries, Keys, and Values

java hashmap foreach: Learn how to use Java HashMap forEach to iterate entries, keys, and values with lambdas, and compare it with traditional loops.

HashMapJava 8forEachiteration
Editorial diagram of two key-value cards merging into one combined entry, illustrating the Java HashMap merge operation.
Java

Java HashMap merge: Syntax and Use Cases

Learn how Java's HashMap.merge combines existing and new values, treats an existing null as absent, and simplifies counting and map-merging logic.

HashMapJava CollectionsMap APIConcurrentHashMap
A diagram showing a HashMap entry being updated in place by the computeIfPresent remapping function.
Java

Java HashMap computeIfPresent: Updating Values In Place

Learn how Java's HashMap computeIfPresent updates existing values, handles null values, and compares with merge and putIfAbsent.

HashMapJava CollectionscomputeIfPresentMap API