🌐
Baeldung
baeldung.com › home › java › java collections › java map › immutable map implementations in java
Immutable Map Implementations in Java | Baeldung
January 23, 2024 - assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); mutableMap.remove("USA"); assertTrue(immutableMap.containsKey("USA")); mutableMap.put("Mexico", "North America"); assertFalse(immutableMap.containsKey("Mexico"));
🌐
Medium
medium.com › threadsafe › java-maps-simplified-understanding-mutable-vs-immutable-implementations-7bd848dde161
Java Maps Simplified: Understanding Mutable vs. Immutable Implementations | by Alireza Alimohammadi | ThreadSafe | Medium
June 29, 2025 - Map<Integer, String> hashMap = new HashMap<>(); // Empty map // Adding entries hashMap.put(1, "a"); hashMap.put(2, "b"); hashMap.put(3, "c"); An immutable map can be quickly initialized using the Map.of(...) method: Map<Integer, String> immutableMap = Map.of(1, "a", 2, "b", 3, "c");
🌐
Guava
guava.dev › releases › 21.0 › api › docs › com › google › common › collect › ImmutableMap.Builder.html
ImmutableMap.Builder (Guava: Google Core Libraries for Java 21.0 API)
static final ImmutableMap<String, Integer> WORD_TO_INT = new ImmutableMap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .put("three", 3) .build();
🌐
Guava
guava.dev › releases › 20.0 › api › docs › com › google › common › collect › ImmutableMap.Builder.html
ImmutableMap.Builder (Guava: Google Core Libraries for Java 20.0 API)
static final ImmutableMap<String, Integer> WORD_TO_INT = new ImmutableMap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .put("three", 3) .build();
🌐
GitHub
github.com › google › guava › blob › master › guava › src › com › google › common › collect › ImmutableMap.java
guava/guava/src/com/google/common/collect/ImmutableMap.java at master · google/guava
* new ImmutableMap.Builder<String, Integer>() * .put("one", 1) * .put("two", 2) * .put("three", 3) * .buildOrThrow(); * } * * <p>For <i>small</i> immutable maps, the {@code ImmutableMap.of()} methods are even more ·
Author: google
🌐
How to do in Java
howtodoinjava.com › home › collections framework › java immutable vs. unmodifiable map: what’s difference?
Java Immutable Vs. Unmodifiable Map: What's Difference?
July 1, 2024 - Map<String, String> mutableMap ...difiableMap); //{key1=value1, key2=value2} Immutable maps guarantee that no change in the underlying map object will ever be visible....
🌐
Guava
guava.dev › releases › 19.0 › api › docs › com › google › common › collect › ImmutableMap.Builder.html
ImmutableMap.Builder (Guava: Google Core Libraries for Java 19.0 API)
static final ImmutableMap<String, Integer> WORD_TO_INT = new ImmutableMap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .put("three", 3) .build();
Find elsewhere
🌐
Java Code Geeks
javacodegeeks.com › home › core java
How to create immutable Map in Java - Java Code Geeks
March 17, 2020 - Map<String, Integer> immutableMap1 = Map.of("a", 1, "b",2, "c",3); //immutableMap1.put("d", 4); //Will throw UnsupportedOperaironException System.out.println("Size of immutableMap1:"+ immutableMap1.size());
🌐
Guava
guava.dev › releases › 23.0 › api › docs › com › google › common › collect › ImmutableMap.html
ImmutableMap (Guava: Google Core Libraries for Java 23.0 API)
Returns a Collector that accumulates elements into an ImmutableMap whose keys and values are the result of applying the provided mapping functions to the input elements.
🌐
Guava
guava.dev › releases › snapshot-jre › api › docs › com › google › common › collect › ImmutableMap.html
ImmutableMap (Guava: Google Core Libraries for Java 999.0.0-HEAD-jre-SNAPSHOT API)
V> ImmutableMap · <K, V> ofEntries · (Map.Entry<? extends K, ? extends V>... entries) Returns an immutable map containing the given entries, in order. final @Nullable V · put · (K k, V v) Deprecated. Unsupported operation. final void · putAll · (Map<? extends K, ?
🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › cloud-service › javadoc › com › google › common › collect › ImmutableMap.html
ImmutableMap (The Adobe Experience Manager SDK 2022.11.9850.20221116T162329Z-220900)
Performance notes: unlike HashMap, ImmutableMap is not optimized for element types that have slow Object.equals(java.lang.Object) or Object.hashCode() implementations. You can get better performance by having your element type cache its own hash codes, and by making use of the cached values to short-circuit a slow equals algorithm. See the Guava User Guide article on immutable collections. ... compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, size
🌐
GitHub
github.com › google › guava › issues › 1238
Add putAll(Iterable<K>, V) to map/immutable map builders · Issue #1238 · google/guava
October 31, 2014 - static { ZipFile zf = new ZipFile("data.zip"); ImmutableMap.<String, ZipFile> builder() .put("file 1", zf) .put("file 2", zf) .build(); } VS: private static final Map<String, ZipFile> map = ImmutableMap.<String, ZipFile> builder() .putAll(Arrays.asList("file 1", "file 1"), new ZipFile("data.zip")) .build(); Reactions are currently unavailable ·
Author: google
🌐
Guava
guava.dev › releases › 33.4.7-jre › api › docs › com › google › common › collect › ImmutableMap.html
ImmutableMap (Guava: Google Core Libraries for Java 33.4.7-jre API)
V> ImmutableMap · <K, V> ofEntries · (Map.Entry<? extends K, ? extends V>... entries) Returns an immutable map containing the given entries, in order. final @Nullable V · put · (K k, V v) Deprecated. Unsupported operation. final void · putAll · (Map<? extends K, ?
🌐
Guava
guava.dev › releases › 29.0-jre › api › docs › com › google › common › collect › ImmutableMap.Builder.html
ImmutableMap.Builder (Guava: Google Core Libraries for Java 29.0-jre API)
static final ImmutableMap<String, Integer> WORD_TO_INT = new ImmutableMap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .put("three", 3) .build();
🌐
Guava
guava.dev › releases › 19.0 › api › docs › com › google › common › collect › ImmutableMap.html
ImmutableMap (Guava: Google Core Libraries for Java 19.0 API)
@GwtCompatible(serializable=true, emulated=true) public abstract class ImmutableMap<K,V> extends Object implements Map<K,V>, Serializable