Java Learning--super Use

Source: Internet
Author: User


* Super: Can be used to modify properties, methods, constructors
 *
when a subclass has a property of the same name as the parent class, you can explicitly call the attribute declared in the parent class by the super. This property.
* If you want to invoke a property with the same name as the subclass "This property"
 *
* *) When a subclass overrides a method of a parent class, it is necessary to use the "super. Method" If you want to explicitly invoke the overridden method of the parent class in the subclass.
 *
Super Modifier constructor: explicitly invokes the constructor specified in the parent class by using "super (formal parameter list)" in the subclass.
* > Inside the constructor, "super (formal parameter list)" must be declared in the first row!
* > Inside the constructor, "This (formal parameter list)" or "super (parameter list)" can only appear one!
* > When the constructor does not explicitly call "this (formal parameter list)" or "super (formal parameter list)" either, the default call is
* constructor for the parent NULL parameter!
* Recommendation: When designing a class, try to provide an empty parameter constructor!

Java Learning--super Use

Related Article

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.