Java Static Code snippet

Source: Internet
Author: User

1) There is also a static block of code in Java in the form of static {...}. The static code block is part of the class definition and is called only once when the class is first loaded, and then the call is no longer loaded. So when did the class first get loaded? is in the main class (the class containing the main function) new an object instance (the class containing the static code snippet does not have a main function) or the class has a main function, then the first load of this class when entering the main function, loading the class when the initialization order is as follows: if there is a parent class, then follow the static member, Static code snippets, static methods, generic members, parent class constructors Initialize the parent class, followed by the initialization of the subclass, in the same order as above.

2) The purpose of the static code snippet is to load the required data when the project is started, and then no longer load redundant data.

Java Static Code snippet

Related Article

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.