java-final keyword __java

Source: Internet
Author: User

Final (final) modified variables, if they are members of the class, the naming requirements are all larger, if it is more than one word, use the underline to separate.
If it is a local constant, you can start with lowercase.

If you do not want subclasses to override some of my methods, you can use the final modifier
Final cosmetic method, which cannot be overridden by a quilt class.

Inline function: Once a method call is encountered: First, an execution field for the current method is saved. Go to the beginning of the current calling method to begin execution.
Method calls, which requires a greater overhead. The reason why you can't write all the code to the main stack is that the space is limited. You may need to allocate a large number of local variables
Direct Memory overflow.
If a method is final decorated, the compiler copies the code directly to the call at the time of compilation, based on the algorithm, in the final method that is called.
Reduces the additional overhead required for method invocations.

Final Terminator.
For immutable variables, just make sure that you assign a value to it before you use it for the first time. Typically, you assign a value when you declare it.
With the final modifier class, the class cannot have subclasses again. If the method in a class is final, you can declare the class as final.

A member of a static modifier whose life cycle is the same as the project's cycle.
is to allocate memory when the class is loaded.
The non-static first is to new an object out. Requires time and space overhead.
The method area has a space size. Static can not be used at random.
If a class does not want to be instantiated by another class, the construction method is privatized.

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.