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();
}
}