Questions about Java Initialization

Source: Internet
Author: User

About the initialization of Java feel that they do not understand, can only understand here, I hope Daniel can guide

Initialization follows

1. When the reference is established

Initializes a static variable for the parent class, and a static code snippet

Initializes the static variables of the subclass, as well as the static code snippet

2 When you create an object

Initializes a static variable for the parent class, and a static code snippet

Initializes the static variables of the subclass, as well as the static code snippet

The normal (global) variables of the parent class are then initialized, along with the normal code snippets and constructors

Initializes the generic (global) variables of the subclass, as well as normal code snippets and constructors

There is only one copy of the static here, and each time the reference is not repeated and does not exist in the heap,

A (global) normal variable does not have an object that is not initialized or does not exist

Static is initialized only once, which is initialized at first use, and constructors and non-static variables are initialized each time they are created.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Questions about Java Initialization

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.