// Created on savesnippets.com ยท https://savesnippets.com/0Muwu8TjU5Tali import java.util.*; class Demo { static final List ROLES = List.of("admin", "editor", "viewer"); static final Set PERMS = Set.of("read", "write", "delete"); static final Map LIMITS = Map.of( "free", 10, "hobby", 100, "pro", 10000 ); void example() { // All throw on mutation attempts // ROLES.add("guest"); // UnsupportedOperationException // For maps with more than 10 entries, use Map.ofEntries: var huge = Map.ofEntries( Map.entry("a", 1), Map.entry("b", 2), // ... up to as many as you like Map.entry("z", 26) ); // Copy any existing collection to immutable form List mutable = new ArrayList<>(List.of(1, 2, 3)); List frozen = List.copyOf(mutable); // snapshot, immutable System.out.println(frozen); } }