This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

what is the unreachable code?

Simo Hayha

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

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 ]

[Blog] [Blogroll] [My Reviews] My Linked In
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: what is the unreachable code?
jQuery in Action, 3rd edition