I'm writing this program in Java and I'm getting a java.util.ConcurrentModificationException. The code excerpt is given below, please let me know if more code is required.
for (String eachChar : charsDict.keySet()) {
if (charsDict.get(eachChar) < 2) {
charsDict.remove(eachChar);
}
}
charsDict
is defined as
Map<String, Integer> charsDict = new HashMap<String, Integer>();
Please help me :)