实例代码:
HashMap<String,Integer> map=new HashMap<String,Integer>();
map.put("1", 1);
map.put("2", 2);
map.put("3", 3);
Set<Map.Entry<String, Integer>> rel=map.entrySet();
for(Map.Entry<String, Integer> entry:rel){
System.out.println(entry.getKey()+" : "+entry.getValue());
}