aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes unreachable statements 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 "unreachable statements" Watch "unreachable statements" New topic
Author

unreachable statements

preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93
Can someone tell me all the possible situations for unreachable statements
I know a few:
- while(false){ ....}
- a return when the try catch finally has return statements


- a statement after a break in an if enclosed in a loop
any other examples?
thanks
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
You can find all rules for unreachable statements at JLS 14.20 Unreachable Statements


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jon Dornback
Ranch Hand

Joined: Apr 24, 2002
Posts: 137
an interesting side note (discovered by accident) is the empty statement (ie, a ";" on a line with nothing else). in java 1.3, a statement like break;; or return;; was accepted by the compiler, but if the same code is compiled under 1.4 it is a compiler error because the second ; is considered an unreachable statement. (not that it has any use, it was just a typo that raised a point about compiler differences).


use the [CODE] tags - it makes it much easier for people to help you.
 
 
subject: unreachable statements