HashMap 的 entryset() 用法
public void hash(){
HashMap<String,Emp> map = new HashMap<>(); //Emp是创建的一个类
for (HashMap.Entry<String,String> map : map.entrySet() ){
System.out.println(map.getKey()); //得到map的键
System.out.println(map.getValue()); //得到map的值,在这里是Emp类的对象
}
}```
在for each循环内注意使用
for ( int i : a[10])
int 相当于 HashMap.Entry<String,Emp> i 相当于 map 代入