package com;
class Test {
public static Test test = new Test();
public static int level = 0;
Test() {
level = 1;
System.out.println("Test() " + level);
}
}
public class Main {
public static void main(String[] arg) {
System.out.println("level " + Test.level);
System.out.println("level " + Test.test.level);
}
}
Output:
Test() 1
level 0
level 0
Q: Это нормально в java? openjdk version «11.0.16» 2022-07-19 OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)