悟空老师,我测试迭代时可以修改呀
package collections.predecessor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Test {
public static void main(String[] args) {
Map<String, Integer> hashMap = new HashMap<>();
hashMap.put("a", 123);
System.out.println(hashMap.get("a"));
Iterator iter = hashMap.keySet().iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
hashMap.put(key, 666);
Integer value = hashMap.get(key);
System.out.println(hashMap.get(key));
}
}
}