SCJP
SCJP
Originally posted by Anup Katariya:
I am getting error for above code.
error is
" illegal forward reference".
I tried it on jdk1.2 and jdk1.4
Thanks
Always say the TRUTH only
Always say the TRUTH only
Originally posted by Prosenjit Banerjee:
Anybody please answer me.
javac simply doesn't yet implement the second bullet of 8.3.2.3.
Originally posted by Valentin Crettaz:
The code compiles fine with Sun's J2SE 1.4.1
See the last example given in JLS 8.3.2.3 Restrictions on the use of Fields during Initialization. On the first line of the first static block, you can see that the variable x is assigned the value 100 even though x is declared later.
The weird thing is that as per the JLS, the code should not compile.
Check out bugs 4281572 and4459133
One of Sun's developers said:
This might explain the issue...
Originally posted by Valentin Crettaz:
that's VERY weird, because I think JDK should pass all "JLS-conformance test" before official release...
Anybody who has taken the time to browse through Sun's Bug database knows that this is not the case![]()
also, what should we answer if the code above appears in exam? (compile successfully or fail?)
This is not going to happen![]()