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