There is a weird case in static block initialization with a static variable. It seems you can put the static block before the declaration, since the following code works! but why?
To make things more weird, the following code won't work! You can't refer the static variable. Error message: "illegal forward reference". Why?
This is explained in the JLS here. Basically, you can use a variable in an initializer block before it's declared in only one way: as the left-hand-side of an assignment statement.
Running a program and accessing i reveals that i is zero!
Initializers are executed in the order present in the source file, effectively resulting in the block
"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.