I played around with this a bit too so I would have a better idea of what's going on. Here are my results:
The result after commenting out the two println statements at the top that will not compile is:
Before Assignment Of Two: 0
After Assignment Of Two: 2
In main: 2
As someone alluded to in another
thread, it has to do with where the variable is used. The left side of the equals sign seems ok, but the right side of the equals sign, or in a println, or anything that requires that the variable be resolved fails to compile and gives the "illegal forward reference" error. The assignment "myStaticInt = 1;" in the code above that occurs before the variable is declared is simply ignored as far as I can tell and the order of execution does seem to be top to bottom.
Hope that helps,
Josh
[ August 25, 2005: Message edited by: Joshua Smith ]