static initializations, is executed only once, the first time you make an object of that class or the first time you access a static member of that class (even if you never make an object of
that class).
I Think The Order of Initialization is :
1. The first time a static method (which is main method)or of class "Numeric" is accessed, the
Java interpreter must locate Numeric.class, which it does by searching through the classpath.
2. As Numeric.class is loaded (creating a Class object), all of its static initializers are run. Thus, STATIC INITIALIZATION TAKES PLACE ONLY ONCE, as the Class object is loaded for the first time.
in your code :
static int i = 5;
static { i=50; } //you try to change i within static block initializer, this is OK, cooz' it's part of the first loaded class.
static int x; //this will give zero by default
{ j = 70; x = 20 } //you try to change x within instance block initializer, this is NOT part of the first loaded class, couz' it's belong to the instance of the class.
thus you still have x = 0.
I bet when you create another Numeric object, you'll get m = 20.
stevie