62,623
社区成员
发帖
与我相关
我的任务
分享
public boolean equals(Object otherObject){
if(this==otherObject)//首先判断是不是引用同一个对象
return true;
if(otherObject==null)//判断otherObject是不是null
return false;
if(getClass()!=otherObject.getClass())//判断是不是属于相同的类
return false;
Employee other=(Employee) otherObject;//强制类型转换
return name.equals(other.name)&&salary==other.salary&&hireDay.equals(other.hireDay);//注意此行
}