java中把父类叫做超类(基类)
在子类中,若想调用父类的成员,用super. 来调用
调用自己的成员 this.
构造方法:
子类构造方法的第一行,有一个隐式代码super();
super() 调用父类的构造方法
super(参数)调用父类有参数的构造方法
eg:
public class Person{
public Person(String name, int age){}
public Person(){} //建议写上空参
}
public student extends Person{
public student(String name,int age){
super(name,age) / /super必须卸载第一行
}
}
不能同时存在super和this() 因为两个都必须在第一行