Student01 stu1 = new Student01("张三",18);不是点,是空格
public class Student {
public static void main(String[] args) {
Student01 stu1 = new Student01("张三",18);
Student01 stu2 = new Student01("李四",19);
Student01 stu3 = new Student01("王五",20);
stu1.setAge(20);
stu2.setName("小明");
Student01.setSchool("B大学");
stu1.info();
stu2.info();
stu3.info();
}
static class Student01{
private String name;
private int age;
//注意:非静态内部类static不能用于内部类的属性
private static String school ="A大学";
public Student01(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public static String getSchool() {
return school;
}
public static void setSchool(String school) {
school = school;
}
public void info(){
System.out.println("姓名:"+this.name+",年龄:"+this.age+",学校:"+this.school);
}
}
}
检查标点符号是否英文