黑马程序员技术交流社区
标题:
面向对象测试类static问题
[打印本页]
作者:
chungo
时间:
2015-9-19 19:25
标题:
面向对象测试类static问题
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,但也有错。怎么处理?
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2