aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes unreachable code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "unreachable code" Watch "unreachable code" New topic
Author

unreachable code

Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
Does anyone know why line 2 is OK?

1) int x = 0;
2) if (false) { x=1; } // OK
3) while (false) { x=2; } // error - unreachable code
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16686
    
  19

It is actually mentioned in the specification. The reason it is okay is to allow for conditional code... like ...



Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: unreachable code
 
Similar Threads
assertions
What is this unreachable error
unreachable statement
Unreachable Statement
Unreachable Code