*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is the unreachable code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is the unreachable code?" Watch "what is the unreachable code?" New topic
Author

what is the unreachable code?

Simo Hayha
Greenhorn

Joined: Jul 02, 2002
Posts: 19
what is the unreachable code?
i tried the following code:
if(false){int i=0;}
it is compiled successful
but when i tried the following code individually:
for(int i=0;false;i++){int j=0;}
while(false){int i=0;}
it can not be compiled!
so what's the unreachable code?
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Please have a look at JLS 14.20 Unreachable Statements
In a nutshell, if(false) is tolerated to allow conditional compilation. for(;false ; ) and while(false) are not allowed by the compiler.
[ August 16, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is the unreachable code?