1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.util.*; import java.lang.*; class Main { public static void main(String[] args) { Set<String> strs = new HashSet<String>(); strs.add("one"); strs.add("two"); strs.add("three"); for (String str : strs) { //note the typo: twos is NOT in the set if (str.equalsIgnoreCase("two")) { strs.remove(str); } } } } |
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CgpjbGFzcyBNYWluCnsKcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgU2V0PFN0cmluZz4gc3RycyA9IG5ldyBIYXNoU2V0PFN0cmluZz4oKTsKICAgIHN0cnMuYWRkKCJvbmUiKTsKICAgIHN0cnMuYWRkKCJ0d28iKTsKICAgIHN0cnMuYWRkKCJ0aHJlZSIpOwoKICAgIGZvciAoU3RyaW5nIHN0ciA6IHN0cnMpIHsKICAgICAgICAvL25vdGUgdGhlIHR5cG86IHR3b3MgaXMgTk9UIGluIHRoZSBzZXQKICAgICAgICBpZiAoc3RyLmVxdWFsc0lnbm9yZUNhc2UoInR3byIpKSB7CiAgICAgICAgICAgIHN0cnMucmVtb3ZlKHN0cik7CiAgICAgICAgfQogICAgfQp9Cn0=
-
upload with new input
-
result: Runtime error time: 0.03s memory: 245632 kB signal: -1
Exception in thread "main" java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793) at java.util.HashMap$KeyIterator.next(HashMap.java:828) at Main.main(Main.java:12)


