方法一:自己写:
public boolean equals(Object b){
Person a = (Person) b;
return this.age==a.age&&this.name.equals(a.name);
}
public int hashCode(){
return this.age*37;//引用的是这个对象的可比性的属性
}
public boolean equals(Object b){
Person a = (Person) b;
return this.age==a.age&&this.name.equals(a.name);
}
public int hashCode(){
return this.age*37;//引用的是这个对象的可比性的属性
}