package dome2;
class people{
int id;
String name ;
int age;
public people(int a,String b,int c) {
id =a;
name =b;
age =c;
}
public void compareage(people p2) {
if (this.age>p2.age) {
System.out.print(this.name+" 大");
}
else if(this.age<p2.age) {
System.out.print(this.name+" 小");
}else {
System.out.print("一样大");
}
}
}
public class test {
public static void main(String[] args) {
people p1= new people(1,"xiaoming",25);
people p2= new people(2,"xiaobai",17);
p1.compareage(p2);
}
}
this练习
最新推荐文章于 2024-10-01 18:51:18 发布