Anyway...
It depends with which compiler you compile the code, but as per the
Java specification (JLS 14.20 Unreachable Statements), such code SHOULD NOT compile.
An excerpt of that section is given below:
[...]
the following statement results in a compile-time
error:
while (false) { x=3; }
because the statement x=3; is not reachable; but the superficially similar case:
if (false) { x=3; }
does not result in a compile-time error. An optimizing compiler may realize that the statement x=3; will never be executed and may choose to omit the code for that statement from the generated class file, but the statement x=3; is not regarded as "unreachable" in the technical sense specified here.
If you read that section entirely, it will become clear to you that only lines 2 and 3 compile correctly. Bottom line, when in doubt, trust the specification and not the compilers which are not always specification-compliant
[ March 18, 2003: Message edited by: Valentin Crettaz ]