Skip to content

Commit 49c7aa1

Browse files
Add files via upload
1 parent 89c8b2d commit 49c7aa1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

IdentityHashMap1.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.util.ConcurrentModificationException;
12
import java.util.IdentityHashMap;
23
import java.util.Iterator;
34
public class IdentityHashMap1 {
@@ -120,7 +121,10 @@ public static void main(String[] args) throws Exception {
120121
System.out.println("Map:" + map);
121122
map.putAll(map1);
122123
System.out.println("Map:" + map);
123-
Iterator<Integer> itr = map.values().iterator();
124+
125+
try{
126+
127+
Iterator<Integer> itr = map.values().iterator();
124128
while (itr.hasNext()) {
125129
System.out.println(itr.next());
126130
}
@@ -131,6 +135,12 @@ public static void main(String[] args) throws Exception {
131135
itr.remove();
132136
}
133137
}
138+
}catch(ConcurrentModificationException e){
139+
e.printStackTrace();
140+
System.out.println(e);
141+
System.out.println(" ");
142+
}
143+
134144
System.out.println("Map:" + map);
135145

136146
// putIfAbsent
@@ -222,6 +232,8 @@ public static void main(String[] args) throws Exception {
222232
System.out.println("ToString:" + s);
223233
System.out.println(" ");
224234

235+
236+
225237

226238

227239
}

0 commit comments

Comments
 (0)