I know there are several ways to iterate through a hashmap, but what is a good way to modify a hashmap as you go along (other than just creating a new hashmap and getting rid of the old one)
I want something like
for (Map.Entry<String, Integer> entry : wordcounts.entrySet()) {
String key = entry.getKey();
Integer value = entry.getValue();
if(blacklist.contains(key))
//remove key/value for that key from wordcounts
if(mappings.contains(key))
//change key in wordcounts from one string to another based on the key's value in a <string,string> map (mappings)
}
Will it be possibly for me to modify my map while I'm going through it? Do i have to use an iterator?