The final keyword for Java

Source: Internet
Author: User

As with static, it is added to achieve some special requirements, and differs from the modifier keywords of ordinary variables.

1.final is the final meaning, so there is no way to modify the meaning inside

So

1.1. A class that is final modified cannot be inherited (childlessness)

1.2. The final modified method cannot be rewritten (and cannot be changed).

1.3. A final modified variable can only be assigned one time, and to be assigned at the time of declaration or the assignment displayed in the construction method (this is also called invariant constant) 1.4.final cannot be used to modify abstract classes, abstract methods, construction methods (this is a supplement to 1.2)

( because abstract classes are used to be inherited, abstract methods are used to be rewritten by others, and construction methods can be rewritten )

The final keyword for 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.