谁来帮忙看看
public class MapDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<Integer,String>map=new HashMap<Integer,String>();
//method(map);
method_01(map);
}
public static void method_01(Map<Integer, String> map) {
// TODO Auto-generated method stub
map.put(6, "wangwu");
map.put(3, "wangcai");
map.put(4, "lisi");
map.put(8, "zhaoliu");
Set<Integer> KeySet=map.keySet();
Iterator<Integer> it=KeySet.iterator();
while(it.hasNext()){
//Integer key=it.next();
String value=map.get(it.next());
System.out.println(it.next()+"...."+value);
}
}
}
Integer key=it.next(); 用这个的时候,it.next()赋值给key,四个值都打印;用上面的代码,不赋值给key就只打印4....wangcai和8....wangwu