Java Static fianl use

Source: Internet
Author: User

1. Scope of Use: Class, method, variable.

2. Distinction and Contact:

2.1.static meaning: Static, statically decorated methods and properties belong to any object that the class does not belong to the class.
2.2.static usage:
2.2.1.static can decorate "inner classes", methods, and member variables.
2.2.2.static "Cannot decorate the outer class", "cannot decorate the local variable" (because static is defined as the class level, so the local level variable is not static decorated).

2.3 Final Meaning: "Can only be assigned once".
2.2.final usage:
A 2.2.1.final decorated property that indicates that the property can only be assigned once, (1) The base type: The value cannot be modified, and (2) the reference type: The reference cannot be modified.
The 2.2.2.final decoration method, which indicates that the method cannot be overridden, but can be accessed by a quilt class if the method is not private type.
A 2.2.2.final decorated class that indicates that a class cannot be inherited.

3. Combined use of static final

3.1. Scope of application:

3.1.2. The intersection of the two ranges, so it can only be modified: member variables, methods, inner classes.

3.2. Meaning: Also the intersection of the two:
3.2.1. Method: A method that belongs to a class and cannot be overridden.
3.2.2. Member variable: A variable that belongs to a class and can be assigned only once.
3.2.3. Inner class: Belongs to an external class and cannot be inherited

Java Static fianl use

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.