- class Person
- {
- private int age;
- Person(int age )
- {}
- public boolean compare(Person p)
- {
- return this.age==p.age;
- }
- }
- class PersonDemo1
- {
- public static void main(String[] args)
- {
- Person p1=new Person(20);
- Person p2=new Person(25);
- boolean b=p1.compare(p2);
- System.out.println(b);
复制代码
为什么结果是true而不是false????
不是20==25吗?
|