public class TestPerson {
public static void main(String[] args) {
Person p1=new Person("xue");
Person p2=new Person("shi");
System.out.print(p1.equals(p2));
}
}
class Person{
String s=null;
@Override
public int hashCode() {
return 50;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return super.equals(obj);
}
public Person(String s) {
super();
this.s = s;
}
}如果equals比较的hash值,那么p1.equals(p2)应该为真