Initialization of the Java class

Source: Internet
Author: User

Class initializes the first time it is "actively used" and assigns the correct initial value to the class (static) variable. In Java code, a correct initial value is given by a class variable initialization statement or static initialization block. And the active use we're talking about here includes:

1. Creating an instance of a class

2. Invoking a static method of a class

3. Using the class's very static field

4. Invoking some of the reflection methods in the Java API

5. Initialize subclasses of a class

6. When a class with the main () method starts

Initializing a class consists of two steps:

1, if the class has a direct parent class, and the immediate parent class has not been initialized, the immediate parent class is initialized first

2. If there is an initialization method for the class, execute this method

Note: Initializing an interface does not require initializing its parent interface.

Initialization of the Java class

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.