When i run this program, it appears that sometimes 55 will be printed out, although i am certain that 6 is the correct behavior.
Or could it be that i was seeing wrong?
public class Test {
static int a = 55;
static {
a = 6;
}
public static void main(String abc[]){
// a is 6
System.out.println(a);
}
}
Edit
I think Cularis got it right, when i shifted the order of the static block and the instantiation and initialization, 55 is printed. It is indeed in texture order.
public class Test {
static {
a = 6;
}
static int a = 55;
public static void main(String abc[]) {
// a is 55
System.out.println(a);
}
}
Have a look at the Java Language Specification, especially