Question about static variable initializers

Hi, I'm going through JLS Third edition, on page 204, where the following example is shown:

package experiments;

/**

*

* @author mtedone

*/

publicclass Z{

staticint peek(){return j;}

staticint i = peek();

staticint j = 1;

/** Creates a new instance of Z */

public Z(){

}

}

package experiments;

import java.util.AbstractCollection;

import java.util.ArrayList;

import java.util.Iterator;

/**

*

* @author mtedone

*/

publicclass Main{

/** Creates a new instance of Main */

public Main(){

}

/**

* @param args the command line arguments

*/

publicstaticvoid main(String[] args){

System.out.println(Z.i);

}

}

Which produces the output zero. JLS explains that the variable initializer for i uses the class method peek() to access the value for j before j is actually initialized with the value of 1. I understood that. However I thought that by changing the order, like the following code:

package experiments;

/**

*

* @author mtedone

*/

publicclass Z{

staticint j = 1;

staticint peek(){return j;}

staticint i = peek();

/** Creates a new instance of Z */

public Z(){

}

}

j would be first initialized to 1, but it still prints zero. Shall I assume, although it appears that JLS doesn't explicitly state so, that class methods in a class variable initializer expression, when these would access other class variables, willalways be executed before the actual class variable they refer to are initialized?

[3468 byte] By [mtedonea] at [2007-11-27 4:21:16]
# 1
> j would be first initialized to 1, but it still prints zero. Prints 1 for me.
Hippolytea at 2007-7-12 9:28:27 > top of Java-index,Java Essentials,New To Java...
# 2
Ah ok, I was using NetBeans-IDE which cached the binaries. I right-clicked on the class and chose 'Run', instead of chosing 'Run Main Project', which refreshes and builds. Apologies
mtedonea at 2007-7-12 9:28:27 > top of Java-index,Java Essentials,New To Java...