【发布时间】:2015-07-25 16:27:28
【问题描述】:
import java.util.*;
class TestCollection13{
public static void main(String args[]){
HashMap<Integer,String> hm=new HashMap<Integer,String>();
hm.put(100,"Amit");
hm.put(101,"Vijay");
hm.put(102,"Rahul");
for(Map.Entry m:hm.entrySet()){
System.out.println(m.getKey()+" "+m.getValue());
}
}
}
在上面的 HaspMap 程序中,我无法理解这个 for 循环背后的逻辑。为什么需要 Map.Entry 以及 entrySet() 的功能是什么? 请帮我解决这个问题。在此先感谢
【问题讨论】:
-
你能把这个链接发给我吗?
标签: java dictionary collections hashmap