Map.Entry是个子接口主要有getKey和getValue方法HashMap hm = new HashMap();
hm.put("Tom","Tom's value");
hm.put("Cat","Cat's value");
Set set = hm.entrySet();
Iterator it = set.iterator();
while(it.hasNext()){
Map.Entry me = (Map.Entry)it.next();
out.println(me.getKey());
out.println(me.getValue());
}iterator对象一般无法更改

解决方案 »

  1.   

    谢谢!
       Map.Entry有个setValue(Object value) 方法,如果用这个方法更新value值,会不会影响Hashtable中的值?
       更改Hashtable中的值只用对Map.Entry中的value有影响吗?
       他们是否是同步的?
      

  2.   

    我觉得是有影响的,也就是说如果使用了setValue是会改变hashtable中的value值。但如果说在赋值以后Map.Entry me = (Map.Entry)it.next();改变了这个next()的值,那么此时对于entry中的getvalue和getkey是不能做到同步的。