大神进来看看啊我初学者
class Person {
private String name;
private int age;
Person(String name,int age) {
this.name = name;
this.age = age;
}
public String info () {
return "name="+name+" age="+age;
}
class Teacher extends Person {
private String vocation;
Teacher(String name, int age, String vocation) {
super (name, age);
this.vocation = vocation;
}
public String info () {
return "name="+name+" age="+age+" vocation="+vocation;
}
}
}
public class XinXi {
public static void main(String args[]) {
Teacher s = new Teacher("a",33,"b");
System.out.println(s.info());
}
}
XinXi.java:29: 找不到符号
符号: 类 Teacher
位置: 类 XinXi
Teacher s = new Teacher("a",33,"b");
^
XinXi.java:29: 找不到符号
符号: 类 Teacher
位置: 类 XinXi
Teacher s = new Teacher("a",33,"b");
^
哪里不对
------解决方案--------------------你把Teacher类写在Person里面去了,成了Person的内部类
------解决方案--------------------貌似你的Teacher类是Person的内部类吧,你应该把Teacher单独写一个类,否则你没有实例化Person类也就无法调用Teacher类