|
@@ -0,0 +1,13 @@
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+public class TestImmutable {
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ HashMap<Integer, Integer> map = new HashMap<>();
|
|
|
|
+ Map<Integer, Integer> immutableMap = Collections.unmodifiableMap(map);
|
|
|
|
+ try {
|
|
|
|
+ immutableMap.put(0, 0);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|