The JLS says A local variable could always be regarded as being created when its local variable declaration statement is executed. The exceptional situation involves the switch statement, where it is possible for control to enter a block but bypass execution of a local variable declaration statement. Because of the restrictions imposed by the rules of definite assignment, however, the local variable declared by such a bypassed local variable declaration statement cannot be used before it has been definitely assigned a value by an assignment expression. Hope this is sufficient. Its just like its possible to initialize finals in the constructor but declare at class level, but cannot be initialized at both places.
You are not comparing like with like. In the first exanple, you are trying to change a final variable which is illegal, but in the second example you are creating a blank final variable and then legally initializing it later. If you changed the blank declaration to something like this: final int i = 1; Then your code will fail to compile.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad: