JAVA类继承出现一点小问题,求高手帮忙!
我定义并且赋值了三个,为啥只输入ZC,而name和age为什么不显示赋值呢?class person
{
private int age;
private String name;
public void per(int age,String name)
{
this.age=age;
this.name=name;
}
public String info()
{
return "name:"+name+"\nage:"+age;
}
}
class teacher extends person
{
private String zc;
private int age;
private String name;
public void teach(String zc)
{
super.per(age, name);
this.zc=zc;
// TODO 自动生成的构造函数存根
}
public String info()
{
return "name:"+name+"\nage:"+age+"\nZC:"+zc;
}
}
public class Clas1 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
teacher t=new teacher();
t.per(19, "TOM");
t.teach("高级工程师");
System.out.println(t.info());
}
}