06_super
- super
- super必须只能出现在子类的方法或子类的构造方法中!
- super调用父类构造方法,必须在构造方法的第一个
- super和this不能同时调用构造方法!
public class Application {
public static void main(String[] args) {
Student student = new Student();
}
}
public class Person {
public Person() {
System.out.println("调用父类构造");
}
}
public class Student extends Person{
public Student() {
super();//隐藏代码,调用父类构造
System.out.println("调用子类构造");
}
}
调用父类构造
调用子类构造
标签:26,调用,构造方法,子类,Student,super,public
From: https://www.cnblogs.com/DivineBrightness/p/18280623