Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map<String, Object> myData = new HashMap<String, Object>();
- myData.put("A", 1);
- myData.put("B", 2);
- for(String key: myData.keySet())
- myData.remove(key);
- This will throw an exception ConcurrentModificationException at runtime
- Map<String, Object> myData = new ConcurrentHashMap<String, Object>();
- myData.put("A", 1);
- myData.put("B", 2);
- for(String key: myData.keySet())
- myData.remove(key);
Add Comment
Please, Sign In to add comment