「Java入門」thisを利用するサンプルコード

サンプルコード:

class this_persion {
private String name;
private int age;

this_persion()
{

}
this_persion(String name)
{
this.name = name ;
}
this_persion(String name,int age)
{
this(name);
this.age = age ;
}
public boolean compare(this_persion p)
{
return this.age == p.age;
}

}
class this_persionStartnews24
{
public static void main(String[] args)
{
this_persion p1 = new this_persion(“山田",35);
this_persion p2 = new this_persion(“島田",25);
boolean b = p1.compare(p2);
System.out.println(b);
}
}

Java

Posted by arkgame