日子过得真快

public class TestStudent {
public static void main(String[] args) {
// 方式1:使用无参构造创建对象,再赋值
Student stu1 = new Student();
stu1.name = "张三";
stu1.age = 18;
stu1.showInfo();
stu1.study();

    // 方式2:使用有参构造创建对象,直接初始化
    Student stu2 = new Student("李四", 20);
    stu2.showInfo();
    stu2.study();
}

}

posted @ 2026-01-06 13:58  111阳  阅读(4)  评论(0)    收藏  举报