Final modifier-Immutable

Source: Internet
Author: User
Final modifier class

Subclass is not allowed.

Modify variable

Once an initial value is obtained, the variable cannot be changed and cannot be assigned a value again.

  Member variables: The initial value must be explicitly set by the programmer and is not implicitly initialized by the system.

     Class variable: Static initialization block | when declaring this type of Variable
Instance variables: Non-static initialization block | when declaring the instance variable | in the constructor
Local variable: The initial value must be explicitly set by the programmer and is not implicitly initialized by the system.
Specified when defining variables | specified in later code
The parameter variable is initialized by the input parameter value, so it cannot be assigned a value.
Basic Type Variable: Values can be assigned only once.
Reference Type Variable: The referenced address will not change, that is, only one object will be referenced, but the object content can be completely changed.
Macro variable:Use final modification to specify the initial value when defining a variable. The final modified variable value can be determined during program compilation.
This variable is essentially a "macro variable". The compiler will replace the place where the variable is used in the program with the value of this variable.

Modifier

Method cannot be overwritten
Use final to modify a private access permission. You can define a method in the subclass that is the same as the method name, parameter list, and return value type as this method.

Final modifier-Immutable

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.