请教一个关于map的问题
程序代码:
java.util.Map<String, String> map1 = new HashMap<String,String>(); map1.put("qq", "qfjhfhgf"); map1.put("ww", "wjhmfugf"); map1.put("ee", "ebncvhfg"); map1.put("rr", "ruyjt"); map1.put("tt", "tbjvn"); map1.put("yy", "yiukfyu"); Set<String> ser = map1.keySet(); Iterator<String> it = ser.iterator(); System.out.println("map1的长度是: "+map1.size()); while(it.hasNext()) { String str6 = it.next(); String str7 = map1.get(str6); System.out.println("key="+it.next()+"; value="+map1.get(it.next()));
程序代码:
while(it.hasNext()) { String str6 = it.next(); String str7 = map1.get(str6); System.out.println("key="+str6+"; value="+str7); }
为什么换成第二种写法就能正常显示了啊 ?