本帖最后由 俊颜魅惑众生° 于 2014-1-24 14:04 编辑
public int hashCode()
{
System.out.println(this.name+".....hashcode");
return this.name.hashCode()+age;
}
public boolean equals(Object obj)
{
if(!(obj instanceof Person1))
{
return false;
}
Person1 p = (Person1)obj;
System.out.println(this.name+"..equals..."+p.name);
return this.name.equals(p.name) && this.age==p.age;
}
这个怎么做比较,怎么调用呢,求解答谢谢 |
|