刚才网上看到
Map<String, String> map = new HashMap<String, String>();
map.put("a", "李荣");
map.put("b", "张明");
map.put("c", "小张");
//方法1:用entrySet()
Iterator it=map.entrySet().iterator();
while(it.hasNext())
{
Map.Entry<String, String> m=(Map.Entry<String, String>)it.next();
System.out.println("键:"+m.getKey()+" 值:"+m.getValue());
}
//方法2:直接在循环中
for(Map.Entry<String, String> m:map.entrySet())
{
System.out.println("键:"+m.getKey()+" 值:"+m.getValue());
}
相关资源:敏捷开发V1.0.pptx