次のデータ フィールドと関数を持つクラス Employee があるとします。プログラムは、 と を比較して 2 が等しいかどうかを確認しようとしますEmployees
。name
address
public class Employee{
private String name;
private double hours;
private double rate;
private Address address;
@Override
public boolean equals(Object obj){
if(obj == this) return true;
if(obj == null) return false;
if(this.getClass() == obj.getClass()){
Employee other = (Employee) obj;
return name.equals(other.name) && address.equals(other.address);
}else{
return false;
}
}
代わりにこれを行わなかったのはなぜpublic boolean equals(Employee obj)
ですか (パラメーターが異なります)。