您好,课堂作业:员工类,用Map遍历出式资大于18000的员工,请问主函数中的for循环中花括号中的第一句中,=号的右边,为什么还要强转到Emp,因为它本来就是Emp对象呀
```java
package map;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* @author 小池
* @version 1.0
*/
@SuppressWarnings({"all"})
public class MapExercise {
public static void main(String[] args) {
Map hashMap = new HashMap();
hashMap.put(1,new Emp("贾宝玉",2000,1));
hashMap.put(2,new Emp("燕青",20000,2));
hashMap.put(3,new Emp("阮小五",30000,3));
System.out.println("====1=====");
Set keySet = hashMap.keySet();
for( Object key:keySet){
Emp emp = (Emp) hashMap.get(key);
if(emp.getSal() > 18000){
System.out.println(emp);
}
}
}
}
class Emp{
private String name;
private double sal;
private int id;
public Emp(String name, double sal, int id) {
this.name = name;
this.sal = sal;
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSal() {
return sal;
}
public void setSal(double sal) {
this.sal = sal;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public String toString() {
return "Emp{" +
"name='" + name + '\'' +
", sal=" + sal +
", id=" + id +
'}';
}
}
```