Instance variables (that are not compile time constants) get initialized in the order that they appear in the source (from top to bottom, and left to right). And any forward reference to them, will have them at their default values.
what about compile time constants?
in what order do they get initialise?
Ankur kothari wrote:since final variables are initialized before all so ....
Note: final variables and compile time constants are not the same thing. The statement that final variables are initialized first, is untrue.
Ankur kothari wrote: ... isn't the statement int a=b+4 actually int a=100+4 ???
Probably. After the optimizer gets to it. However, there is nothing in the JLS that allows compile time constants to be exempted from the forward referencing rules... so, this is still illegal according to the spec.