本帖最后由 zsz3278440 于 2015-3-10 11:22 编辑
class Person
{
private int age;
Person(int age)
{
this.age=age;
System.out.println(age);
}
public boolean compare(Person p)
{
return this.age==p.age;
}
}
class PersonDemo
{
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);
}
}
新人求教,age用private修饰了以后,为什么在return this.age==p.age中还可以用p.age?
|
|