Java blank final, javafinal

Source: Internet
Author: User

Java blank final, javafinal

Java 1.1 allows us to create "blank final", which belongs to some special fields. Although declared as final, no initial value is obtained.

In either case, Blank final MUST be correctly initialized before actual use (Blank finals MUST be initialized in the constructor :). Moreover, the compiler will take the initiative to ensure that this provision is implemented.

However, blank final has the maximum flexibility for various final keyword applications.

For example, a final field inside the class can be different for each object, while still keeping its "unchanged" nature. The following is an example:

/*** Created by xfyou on 2016/11/2. * blank final demo */public class BlankFinal {private final int I = 0; private final int j; private final Poppet p; public BlankFinal () {j = 1; p = new Poppet ();} public BlankFinal (int j) {this. j = j; p = new Poppet ();} public static void main (String [] args) {BlankFinal bf = new BlankFinal () ;}} class Poppet {}

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.