Execution order of java programs

I would like to ask all the great gods the execution order of the following code. I have been wondering what the execution order is. I hope there will be a big boss to give me an answer. Thank you very much ~
public class ExeOrder1 {

.
public static int k=0;
public static ExeOrder1 e1 = new ExeOrder1("t1");
public static ExeOrder1 e2 = new ExeOrder1("t2");
public static int i = print("i");
public static int n=99;
public int j=print("j");

{
    print("");
}
static{
    print("");
}
public ExeOrder1(String str){
    System.out.println((PPk)+":"+str+"  i="+i+"   n="+n);
    PPi;
    PPn;
}

public static int print(String str){
    System.out.println((PPk)+":"+str+"  i="+i+"   n="+n);
    PPn;
    return PPi;
}
public static void main(String[] args){
    ExeOrder1 e=new ExeOrder1("init");
}

}

the following is the result of the run:
1
2: building block item1
3:t1 item2
4 br > 4 viz. 3 nude 3
5: building block 4 naphtha 4
6:t2 iota 5
7 br iota 6 naphtha 6
8: static block iport 7 naphtha 99
9J iprit 8 nude 100
, the following is the result of the operation:
4
4
5: the following is the result of the run:
1
2: block iota 1
2
4
5: block 4
5
7
8: static block

Apr.11,2021

read the following article and you will understand. The link describes


java code execution order. Anyone who understands the jvm class loading mechanism should know that a class will first load static methods and variables during loading, so the above code should first execute the static code block. As for this mian method, I don't know the loading sequence relationship between it and other static code. If there is something wrong, please point out


in fact, this code is not difficult to understand, just pay attention to a few points: static variable will only initialize once , when initializing, int will be assigned to 0
, so this means that this static variable will only run when first loads this class.

then look at the code:
notice in the main method this class has initialized for the first time, that is, the following code:

public static int i = print("i");
public static int n=99;
static{       //
    print("");
}
public int j=print("j");  //
{
    print("");
}
public ExeOrder1(String str){  //
    System.out.println((PPk)+":"+str+"  i="+i+"   n="+n);
    PPi;
    PPn;
}

so what you see in the end is the following result:

1:j  i=0   n=0
2:  i=1   n=1
3:t1  i=2   n=2
4:j  i=3   n=3
5:  i=4   n=4
6:t2  i=5   n=5
7:i  i=6   n=6
8:  i=7   n=99
9:j  i=8   n=100
10:  i=9   n=101
11:init  i=10   n=102
Menu