In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Java constructor, static code block, what is the execution order of the construction code block", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "Java constructor, static code block, what is the execution order of the construction code block"!
Static code block: declared static, executed when jvm loads the class, executed only once.
Construction code block: Defined by {}, executed each time an object is created.
Constructors: The constructor is invoked as soon as the object is created.
static code block
1. It is executed as the class is loaded, only once, and better than the main function, static code blocks are called by the class. Class, execute the static code block first, and then execute the main function. 2. Static code blocks are for class initialization, construction code blocks are for object initialization. 3. Variables in static code blocks are local variables, just like local variables in ordinary functions. 4. There can be multiple static code blocks in a class.
static{} construct code block
1. The constructor code block initializes the object, runs the constructor code block as soon as the object is created, and executes before the constructor. Constructor blocks are run only when objects are created, classes cannot invoke constructor blocks. 2. Constructor code blocks are initialized uniformly for objects, while constructors are initialized for specific objects. There may be multiple constructors, and different initializations will be performed without calling constructors, while constructor code blocks will be executed.
{} constructor
1. Once the object is created, it calls the constructor, which means that it doesn't call the constructor until it's created. 2. Constructors initialize objects. 3. When an object is created, the constructor is called only once, whereas normal functions are called multiple times.
public void Rumenz(){} At this point, I believe that everyone has a deeper understanding of "Java constructor, static code block, construction code block execution order is what", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.