How to use Super:
Super specifically is the object of the parent class, since it is the object of the parent class normally can be used like objects,
For example, some method variables such as Super.math () are called directly, such as: super.variable;
The first sentence placed in the constructor method calls the constructor of the parent class as follows:
Chassfather
{
Publicfather ()
{
}
}
Chass Son extends Father
{
Publicson ()
{
Super ();//This is the parameterless construction method that called the parent class. It must be placed in a subclass of the constructor method of the valid code
The first sentence (emphasis 1) is placed in the constructor of the subclass. Focus 2, must be the first sentence of the valid code)
System.Out.Println ("The first sentence is the method of calling the parent class, the following is the initialization of the subclass");
}
}
Add: 1. If you want to invoke the parent class's constructor with parameters, the subclass is super (), and the corresponding arguments are passed in parentheses. 2. "This usually refers to the current object, and super usually refers to the parent class"
Java Classroom Assignment 06