/** * Created by xabcd on 2019/2/16. */ public class person_equals { private String name; private int age; public person_equals(String name,int age) { this.name = name; this.age = age; } }
/**
* Created by xabcd on 2019/2/16.
*/
public class test_equals1
{
public static void main(String[] args) {
person_equals p1 = new person_equals("张三", 25);
person_equals p2 = new person_equals("张三", 25);
System.out.println(p1.equals(p2) ? "是同一个人" : "不是同一个人");
}
}
结果:
不是同一个人