java中的Map.Entry<String,String> set:map.entrySet()

代码:

Map map = new HashMap<>();
map.put("张三","1212");
map.put("王五","jsd");
for(Map.Entry set:map.entrySet()){
    System.out.println(set);//{张三=1212,王五=js}
    System.out.println(set.getKey()+set.getValue());
}

1. Set> entrySet() {

Set> es;
return (es = entrySet) == null ? (entrySet = new EntrySet()) : es;

} //返回该类型的set集合:{张三=1212,王五=js}

 

 

你可能感兴趣的:(编程,java)