日期:2014-05-20 浏览次数:20767 次
class AA{
String name;
int age;
public AA(){}
public String talk()
{
return("姓名:"+name+"\n年龄:"+age);
}
}
class BB extends AA{
String school;
public BB(String name,int age,String School)
{
super.name=name;
super.age=age;
System.out.println(super.talk());
this.school=school;//赋值没有生效 }
}
public class TestSuper {
public static void main(String[] args) {
// TODO 自动生成的方法存根
BB b1=new BB("张三",20,"北大");
System.out.println("学校:"+b1.school);
}
}