Normally the
Java compiler stops with an error if you have unreachable code (code which is in a place where the compiler knows it will never be executed). Therefore, you would expect that this is not allowed:
But this is a special case that is allowed, see
Conditional compilation in the Java Language Specification.
The idea to allow this is to make it easy for developers to temporarily "comment out" a block of code, for debugging /
testing purposes.
Also see
14.21 Unreachable statements.