Java blank final, Java blank final

Source: Internet
Author: User

Java blank final, Java blank final

Blank final refers to the domain declared as final but not given an initial value.

The final must be assigned a value at the definition of the domain or each constructor using an expression to ensure that the final must be initialized before use.


Java blank final

Blank final values can be assigned without definition. The variables a and f defined in the main class are correct.
The problem lies in the constructor. In the two constructor, only one of them will be called during instantiation, resulting in a variable not initialized.
For example, when FinalTest x = new FinalTest (2);, a has a value, but f is not initialized.

In java, what is final used in parameters?

Final variable modification means that the reference of the variable is unchangeable. In your example, the reference of helloService cannot be re-assigned ..

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.