我知道有几种方法可以遍历哈希图,但是什么是修改哈希图的好方法(除了创建一个新的哈希图并摆脱旧的哈希图)
我想要类似的东西
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)
}
在我浏览地图时是否可以修改我的地图?我必须使用迭代器吗?