public class TestHashCode {
public static void main(String[]args){
int i=5,j=5;
System.out.println(i==j);
Person p1=new Person(0);
Person p2=new Person(0);
if(p1==p2){
System.out.println("p1==p2");
}else {
System.out.println("p1!=p2");
}
if(p1.equals(p2)){
System.out.println("p1 is equals to p2");
}else{
System.out.println("p1 is not equals to p2");
}
p2=p1;
System.out.println(p1==p2);
System.out.println(p1.equals(p2));
}
}
equals()比较内容 “==”比较地址,为什么p1.equals(p2)为false 呢?
慕桂英3389331
茅侃侃