public int hashCode(){
return this.getName().hashCode()+age*60;
}
public boolean equals(Object obj){
if(!(obj instanceof Students))
throw new ClassCastException("类型不匹配");
Students s = (Students)obj;
return this.name.equals(s.name) && this.age==s.age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public String toString(){
return name+"...."+age;
}
} 作者: 15670379287 时间: 2016-3-29 23:53
不明觉厉