本帖最后由 黑白小調° 于 2014-1-14 08:13 编辑
这里的this分别代表什么呢?P1、P2代表什么呢?
class person
{
private String name;
private int age;
Person(int age)
{
this.age=age;
}
Person(String name)
{
this.name=name;
}
Person (String name,int age)
{
this.name=name;
this.age=age;
}
public void speak()
{
System.out.println("name="+name+"...age="+this.age);
this.show;
}
public void show()
{
System.out.println(this.name);
}
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=P1compare(P2);
System.out.println(b);
}
} |