This distinction matters for defensive copying: copyOf is safe to hand out, a view still reflects later changes to the source.
var source = new ArrayList<>(List.of("a"));
List<String> snapshot = List.copyOf(source);
List<String> view = Collections.unmodifiableList(source);
source.add("b");
System.out.println("List.copyOf snapshot : " + snapshot);
System.out.println("unmodifiable view : " + view);
List.copyOf snapshot : [a]
unmodifiable view : [a, b]
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-07-30