public boolean equals(Object otherObject) {
// a quick test to see if the objects are identical
if (this == otherObject) return true;
// must return false if the explicit parameter is null
if (otherObject == null) return null;
// if the classes don`t match, they can`t be equal
var other = (Employee) otherObject;
// test whether the fields have identical values
return Objects.equals(name, other.name)
&& salary == other.salary && Object.equals(hireDay, other.hireDay);
}
[Java核心技术(卷Ⅰ)] - 判断相等
猜你喜欢
转载自blog.csdn.net/piano9425/article/details/111165174
今日推荐
周排行