J.IV · Java 25 practice question

Which set of static factory methods on java.util.Map is documented as the convenient way to create unmodifiable maps in Java SE 25?

Choose one answer
Check answer and explanation

Correct answer: Map.of, Map.ofEntries, and Map.copyOf

Explanation

The Java SE 25 Map API explicitly lists Map.of, Map.ofEntries, and Map.copyOf as the static factory methods for creating unmodifiable maps.

Common trap

Map.fromEntries and Map.unmodifiable do not exist; Collections.unmodifiableMap is a separate wrapper utility. Map.create and Map.cloneOf are invented names not present in java.util.Map.

Source: Java SE 25 API: Map
Checked against the cited text on 2026-11-25.

Report an error in this question