Browse by Topic

Popular

Latest

Latest Posts

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
Professional illustration of a Java HashMap using computeIfAbsent to insert a new list value when a key is absent
Java

Java HashMap computeIfAbsent: Syntax and Use Cases

Learn how HashMap.computeIfAbsent works: its syntax and behavior, and when to choose it over putIfAbsent or compute for building maps.

HashMapJava CollectionsMap APIFunctional Programming
Illustration of a Java HashMap entry being updated in place by a compute remapping function
Java

Java HashMap compute: In-Place Value Updates

HashMap.compute updates an entry in place with a remapping function. See when to use it, how it differs from merge and computeIfAbsent, and common pitfalls.

JavaHashMapMap APIFunctional Programming
Diagram showing a HashMap entry being updated with the replace method, illustrating key existence check.
Java

Java HashMap replace: Update Existing Entries

java hashmap replace: Learn how the Java HashMap replace method works, its two overloads, return values, and when to use it instead of put.

HashMapJava CollectionsMap InterfaceReplace Method
Diagram of a Java HashMap showing a linear scan across value entries to find a matching value
Java

How HashMap containsValue Works in Java

java hashmap containsvalue: Learn how HashMap.containsValue works in Java, including its O(n) time complexity, equals-based comparison, null handling, and when to pref...

JavaHashMapcontainsValueJava Collections
A magnifying glass over a Java HashMap key-value pair representing the containsKey lookup operation.
Java

Java HashMap containsKey: Usage and Performance

Learn how to use HashMap.containsKey to check key existence, understand its null-key behavior, performance, and common pitfalls in Java.

HashMapcontainsKeyJava CollectionsMap Lookup
Illustration of a Java HashMap entry being removed by a key, with a focus on the removal operation.
Java

Java HashMap remove: Syntax, Return Values, and Pitfalls

Learn how to remove entries from a Java HashMap, including return values, null handling, iteration safety, performance tradeoffs, and common pitfalls.

HashMapJava CollectionsMap RemovalIteration
Illustration of a HashMap with a key lookup returning a default value when the key is missing
Java

Using HashMap getOrDefault in Java

Learn how to use HashMap.getOrDefault in Java to return a fallback value for missing keys, handle null values correctly, and avoid verbose null checks.

HashMapJava MapgetOrDefaultJava Collections
Illustration of a Java HashMap get operation showing a key mapping to a value through a hash bucket.
Java

Java HashMap get(): Lookup Behavior and Common Pitfalls

Understand how Java's HashMap.get() works, including hashing behavior, performance, null handling, thread safety, and common mistakes when retrieving values.

HashMapJava CollectionsMap LookupJava Performance
Illustration of a Java HashMap being updated with a key-value pair only when the key is missing, showing a checkmark on a key.
Java

Java HashMap putIfAbsent: Usage and Behavior

Understand how Java HashMap putIfAbsent works: its return value, null-handling behavior, concurrency implications, and when to prefer it over put or computeIfAbsent.

JavaHashMapputIfAbsentMap