import java.util.*; public class Demo { public static void main(String[] s) { Hashtable<String,String>hash = new Hashtable<String,String>(); hash.put("key1", "value1"); hash.put("key2", "value2"); hash.put("key3", "value3"); System.out.println("Initial collection: "+hash); Map map= Collections.unmodifiableMap(hash); // error will generate map.put("key3", "value3"); } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more