package day08;
public class Grade1Student extends Student{
private String name;
private int age;
private String sex;
private String School;
private static int grade;
public Grade1Student() {
super();
// TODO Auto-generated constructor stub
}
public Grade1Student(String name, int age, String sex, String name2,
int age2, String sex2, String school, int grade) {
super(name, age, sex, name2, age2, sex2, school, grade);
// TODO Auto-generated constructor stub
}
public Grade1Student(String name, int age, String sex) {
super(name, age, sex);
// TODO Auto-generated constructor stub
}
public Grade1Student(String name, int age) {
super(name, age);
// TODO Auto-generated constructor stub
}
public Grade1Student(String name, int age, String sex, String school) {
super();
this.name = name;
this.age = age;
this.sex = sex;
School = school;//静态变量没有this关键字
}
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 String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getSchool() {
return School;
}
public void setSchool(String school) {
School = school;
}
public static int getGrade() {
return grade;
}
public static void setGrade(int grade) {
Grade1Student.grade = grade;
}
}
//我想创建一个四年级的学生类,于是把年级定义成静态
但是eclipse自动给出的Gradeget set方法也是静态的,但是报错了 为什么?
方法去掉static之后就OK了
这是在同一个类里面 而且都是静态的 为什么会报错啊 静态调用静态 思想没错吧 |
|