People p1 = new People(21,"lisi");
People p2 = new People(21,"lise");
p2= p1;
p2.setAge(1);
System.out.println(p1.getAge());
System.out.println(p2.getAge());
System.out.println(p1.equals(p2));
System.out.println(p1==p2);
class People{
int age;
String name;
public People(int age, String name) {
super();
this.age = age;
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
结果:
1
1
true
true |
|