myeclipse程序如下却没结果是为什么
classDay5_7_ThisDemo//程序实现对两人同龄与否的判断{publicstaticvoidmain(String[]args){Personp1=newP...
class Day5_7_ThisDemo //程序实现对两人同龄与否的判断
{
public static void main(String[] args)
{
Person p1=new Person("ab",14);
Person p2=new Person("abc",14);
p1.compare(p2);
}
}
class Person
{
private String name;
private int age;
Person(String name,int age)
{
this.name=name;
this.age=age;
}
boolean compare(Person p)
{
return this.age==p.age;
}
} 展开
{
public static void main(String[] args)
{
Person p1=new Person("ab",14);
Person p2=new Person("abc",14);
p1.compare(p2);
}
}
class Person
{
private String name;
private int age;
Person(String name,int age)
{
this.name=name;
this.age=age;
}
boolean compare(Person p)
{
return this.age==p.age;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询