对这个地方不懂
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + month;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((speices == null) ? 0 : speices.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
//判断对象是否相等,相等则返回true,不用继续比较属性了
if (this == obj)
return true;
//判断obj是否为Cat类对象
if (obj.getClass()== Cat.class) {
Cat cat=(Cat)obj;
return cat.getName().equals(name)&&(cat.getMonth()==month)&&(cat.getSpeices().equals(speices));
}
return false;
}
}
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 7317 份
- 解答问题 14452 个
想要入门学编程?多年一直活跃在编程语言排行版前列的Java是一个很好的选择。本路径将从Java基础语法、面向对象、常用工具类三部分,为你开启软件开发的大门!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星