Junior — Middle
What approaches ensure the immutability of a List collection within a class?
sobes.tech AI
Answer from AI
To make a List immutable in Java, use Collections.unmodifiableList to wrap a copy of the list, or use List.copyOf() in Java 9+. Returning copies in getters also helps. Guava's ImmutableList is another option.