解释一下输出结果是怎么产生的?
public class Text {
public static int k = 0;
public static Text t1 = new Text("t1");
public static Text t2 = new Text("t2");
public static int i = print("i");
public static int n = 99;
public int j = print("j");
static {
print("静态块");
}
public Text(String str) {
System.out.println((++k) + ":" + str + " i=" + i + " n=" + n);
++i;
++n;
}
public static int print(String str) {
System.out.println((++k) + ":" + str + " i=" + i + " n=" + n);
++n;
return ++i;
}
public static void main(String args[]) {
new Text("init");
}
}
1:j i=0 n=0
2:t1 i=1 n=1
3:j i=2 n=2
4:t2 i=3 n=3
5:i i=4 n=4
6:静态块 i=5 n=99
7:j i=6 n=100
8:init i=7 n=101