The super in Java

Source: Internet
Author: User
Super appears in subclasses that inherit from the parent class.
There are three ways of being present:
First Kind
super.xxx; (XXX is the variable name or object name)
The meaning of this method is to get a variable or method reference in the parent class whose name is XXX.
You can use this method to directly access variables or objects in the parent class, modify assignments, and so on.
The second Kind
Super.xxx ();(xxx for method name)
This method is meant to directly access and invoke methods in the parent class.
Third Kind
Super ();
This method means that the invocation of the parent class's initialization method is actually called the Public xxx () method in the parent class-----but not limited to the direct parent class, which can be traced up

When a subclass calls a constructor method, it first calls the constructor of the parent class, and then calls its own construction method.

Super () and this () call constructor method overload must be written in the first sentence, the other code is written behind it

The super in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.