package facetoface;
class Student{
public String name;
public int 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 Student(String name, int age) {
super();
this.name = name;
this.age = age;
}
public Student() {
super();
}
public void show(){
System.out.println(name+"-----"+age);
}
class Undergraduate extends Student{
private String degree;
public Undergraduate(){
}
public Undergraduate(String name,int age,String degree){
super.name=name;
super.age=age;
this.degree=degree;
}
public void show(){
System.out.println(name+"----"+age+"----"+degree);
}
}
public class facetoface01 {
public static void main(String[] args) {
Student s=new Student("学生a",12);
Student.show();
Undergraduate ug=new Undergraduate("毕业生a",14,"本科");
Undergraduate.show();
}
}
}
测试类里面static报错,系统提示不断的加static,但也有错。怎么处理? |