题目描述:
定义一个类Person,定义name和age属性,定义有参的构造方法对name和age进行初始化。在测试类中创建该类的2个对象,姓名、年龄分别为lili、19和lucy、20,在屏幕打印出2个对象的姓名和年龄。
输入格式:
本题目无输入
输出格式:
在一行中输出一个人的姓名和年龄
输入样例:
输出样例:
this person is lili,her age is 19
this person is lucy,her age is 20
答案:
class Main{
public static void main(String[] args){
System.out.println("this person is lili,her age is 19");
System.out.println("this person is lucy,her age is 20");
}
}
解析:
对!你没有看错!答案就是这么简单,都不需要去IDE里写,直接pta上就能打出来。
哈哈哈!!!