dengxinyi 6 năm trước cách đây
mục cha
commit
b0247d30ff
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      basis/concurrent/TestImmutable.java

+ 13 - 0
basis/concurrent/TestImmutable.java

@@ -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();
+        }
+    }
+}