Ritesh raushan wrote:this question also discuss in javaranch but didn't clearify . . .
That can’t be true. No, no, no, no, no.
This
is JavaRanch.
Instance members do not have an order, but
static blocks do. Joshua Bloch says, in
Effective Java, says that multiple
static blocks (well, actually initialisers) are a potent source of confusion. Because they have an order, the field
x is initialised to 66 and later to 6, in the first example. Executed in the order the code was declared in.
In the second example, it is the other way round.
You can read about static initialisers in the
Java Language Specification; I haven’t read that section for a long time. I think I quoted the right bit. I do not know whether multiple instance initialisers are also executed in the order they are declared.