Super keyword of Java
Super keyword of Java
Don't say much, just go to the code:
Super is used to restrict the object to call instance variables or methods inherited from the parent class. Therefore, like this, super cannot appear in static modified methods. (because the static modified method belongs to a class, the caller will be a class, not an object)
Call parent class member variable
Summary:
Call the method of the parent class
As we said before, the instance method defined in the subclass with the same name as the parent class and the same parameter list (static method cannot be overridden) is the so-called method override. At this time, the subclass's method will override the parent's method.
Call the parent class constructor
In the previous article, a summary has been made about using the super keyword to call the parent class constructor in the subclass. For details, see: talking about constructor again in Java inheritance
Reference books: Thinking in Java, crazy Java handout