public static void main(String[] args) {
Map<String,Integer> map=new HashMap<String,Integer>();
map.put("a", 1);
map.put("b", 2);
map.put("c", 3);
//entrySet()的返回值也是返回一个Set集合,此集合的类型为Map.Entry;接口中有getKey(),getValue方法
for(Map.Entry<String,Integer> eny : map.entrySet() ){
System.out.println(eny.getKey()+"====="+eny.getValue());
}
for(String enn : map.keySet()){//遍历key
System.out.println("key"+"==="+enn);
}
for(Integer enn : map.values()){//遍历value
System.out.println("value"+"==="+enn);
}
}
Map<String,Integer> map=new HashMap<String,Integer>();
map.put("a", 1);
map.put("b", 2);
map.put("c", 3);
//entrySet()的返回值也是返回一个Set集合,此集合的类型为Map.Entry;接口中有getKey(),getValue方法
for(Map.Entry<String,Integer> eny : map.entrySet() ){
System.out.println(eny.getKey()+"====="+eny.getValue());
}
for(String enn : map.keySet()){//遍历key
System.out.println("key"+"==="+enn);
}
for(Integer enn : map.values()){//遍历value
System.out.println("value"+"==="+enn);
}
}