public class test1 {
public static class Student {
private String name;
private int age;// 不再显式定义构造函数// Java会自动提供一个默认的无参构造函数
public String getName(){return name;}
public voidsetName(String name){
this.name = name;}
public intgetAge(){return age;}
public voidsetAge(int age){
this.age = age;}
@Override
public String toString(){return"Student{"+"name='"+ name +'\''+", age="+ age +'}';}}
public staticvoidmain(String[] args){
Student student = new Student();// 使用默认构造函数
student.setName("John Doe");
student.setAge(20);
System.out.println(student);}}