for the following code:
class A
{
public static int X;
static { X = B.Y + 1;}
}
public class B
{
public static int Y = A.X + 1;
static {}
public static void main(String[] args) {
System.out.println("X = "+A.X+", Y = "+B.Y);
}
}
the output is:
X = 1, Y = 2
Why? And How?
P.S: Code snippet taken from JavaCamp.org