package?k;
public?class?Dog?{
int?age;
String?name;
public?boolean?equals(Object?obj)?{
if?(this?==?obj)
return?true;
if?(obj?==?null)
return?false;
if?(getClass()?!=?obj.getClass())
return?false;
Dog?other?=?(Dog)?obj;
if?(age?!=?other.age)
return?false;
if?(name?==?null)?{????????????????????????//從這里
if?(other.name?!=?null)
return?false;
}?else?if?(!name.equals(other.name))
return?false;??????????????????????//到這里
return?true;
}
}視頻中只有一個int變量,而這里多了個String變量,生成的代碼就不會了
添加回答
舉報
0/150
提交
取消