In many traditional languages, programs are loaded as a one-time part of the startup process. The subsequent initialization, and then the formal execution of the program. In these languages, the initialization process must be carefully controlled to ensure that the initialization of static data does not cause trouble. For example, when a static data is initialized, another static data is expected to be a valid value, which can cause problems in C + +.
Java does not have such a problem, because it uses a different load method. Because everything in Java is an object, many activities become simpler, and the problem is one example. As the next chapter will cover, the code for each object exists in a separate file. The file is not loaded unless you really need the code. In general, we can assume that unless an object of that class is constructed, the code is not actually loaded. Because of the subtle ambiguity of the static method, it is also considered that "class code is loaded at first use."
The first place to use is also where static initialization occurs. When loaded, all static objects and static code blocks are initialized in their original order (that is, the order in which they are written in the class definition code). Of course, static data is initialized only once.