私はクラスを持っています 学校:
public class School{
private int noOfTeachers;
private int noOfStudents;
//setters and getters....
public boolean equals(Object that){
//instance of check..
return (this.noOfTeachers == ((School)that).noOfTeachers ||
this.noOfStudents== ((School)that).noOfStudents);
}
public int hashCode(){
//What goes in here??? o.O
}
}
hashCodeこのクラスの の実装をどのように進める必要がありますか? ハッシュの計算と のnoOfTeachers両方を含む戦略を考えることができません。noOfStudentsむしろnoOfTeachersと の組み合わせはとnoOfStudentsの間の契約に違反しているようです。equalshashCode