Java Class Attribute inheritance relationships

Source: Internet
Author: User

In Java, where subclasses inherit the parent class and want to overwrite a field in the parent class, you can declare a property in the subclass that is exactly the same as the property name and type in the parent class, and calling these properties in the subclass is the attribute that is defined in the calling subclass, not the attribute from the parent class. The value of the property with the same name in the parent class is not affected by the same name attribute in the child class, that is, the attribute in the subclass cannot overwrite the property in the parent class, and if you want to modify the property in the parent class, only through the set method or directly to the attribute amplitude in the parent class, without the case that the subclass overrides the

This article is from the "Flying Fish Technology" blog, please be sure to keep this source http://flyingfish.blog.51cto.com/9580339/1722337

Java Class Attribute inheritance relationships

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.