public class Main {
static int x = Main.y;
// static int x = y; //Not allowed; y is not defined
static int y = x;
public static void main(String[] args) {
System.out.println(x);//prints 0
}
}
How come I am allowed to use y trough the class, but not directly?
When is y defined?
The precise rules governing forward reference to class variables are described in the section §8.3.2.3 of the JLS: