File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .ConcurrentModificationException ;
1
2
import java .util .IdentityHashMap ;
2
3
import java .util .Iterator ;
3
4
public class IdentityHashMap1 {
@@ -120,7 +121,10 @@ public static void main(String[] args) throws Exception {
120
121
System .out .println ("Map:" + map );
121
122
map .putAll (map1 );
122
123
System .out .println ("Map:" + map );
123
- Iterator <Integer > itr = map .values ().iterator ();
124
+
125
+ try {
126
+
127
+ Iterator <Integer > itr = map .values ().iterator ();
124
128
while (itr .hasNext ()) {
125
129
System .out .println (itr .next ());
126
130
}
@@ -131,6 +135,12 @@ public static void main(String[] args) throws Exception {
131
135
itr .remove ();
132
136
}
133
137
}
138
+ }catch (ConcurrentModificationException e ){
139
+ e .printStackTrace ();
140
+ System .out .println (e );
141
+ System .out .println (" " );
142
+ }
143
+
134
144
System .out .println ("Map:" + map );
135
145
136
146
// putIfAbsent
@@ -222,6 +232,8 @@ public static void main(String[] args) throws Exception {
222
232
System .out .println ("ToString:" + s );
223
233
System .out .println (" " );
224
234
235
+
236
+
225
237
226
238
227
239
}
You can’t perform that action at this time.
0 commit comments