Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableMapExample2 { public static void main(String[] args) { Map<Integer, String> map = new HashMap<>(); map.put(1, "one"); map.put(2, "two"); System.out.println("Initial Unmodifiable Map: "+map); Map<Integer, String> map2 = Collections.unmodifiableMap(map); map2.put(3, "three"); } }
Output