hi all,
According to the JLS 12.4(Initialization of Classes and Interfaces):
A class or interface type will be initialized immediately before the first occurence of any one of the following:
1)T is class and an instance of T is created.
2)T is a class and a static method declared by T is invoked.
3)A static field declared by T is used and the reference to the field is not a compile-time constant. References to compile-time constants must be resolved at compile time to a copy of the compile-time constant value, so uses of such a field never cause initialization.
now see this code:
the o/p is:
the value of j is = 30
20
My question is that how the first line getting printed when niether 1), 2) and 3) point also coming to play???
we r not calling any static method and we are assinging a compile-time constant to variable x......
how j is getting initialized?? plz clarify anyone!!!
thanx
amit