Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- ConcurrentHashMap<String, String> c = new ConcurrentHashMap<String, String>();
- c.put("1", "a");
- c.put("2", "b");
- c.put("3", "c");
- c.put("4", "d");
- // The following code won't fail
- for (Map.Entry<String, String> entry : c.entrySet()) {
- c.put("5", "e");
- System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
- c.put("6", "f");
- }
- // another flavour of the above code which would fail neither
- for(String str:c.keySet()) {
- c.put("5", "e");
- System.out.println(c.get(str));
- c.put("6", "f");
- }
- }
Add Comment
Please, Sign In to add comment