wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes unreachable statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "unreachable statement" Watch "unreachable statement" New topic

unreachable statement

sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257

gives unreachable statement at 6. is it bcos line 7 is not reached?

Sunita<br />SCJP 1.4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The syntax for a while statement is: while(boolean_condition) statement;
If, as in your example, boolean_condition is false, then statement is unreachable.
Beacause a block which is { statement; ... } IS a statement the message that line 6 is unreachable is correct.
Sort of...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Thanks Barry
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Also check out JLS 14.20 Unreachable Statements

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link: http://aspose.com/file-tools
subject: unreachable statement
Similar Threads
while(false) vs. if(false)
Assert Doubt
Interesting thing about while
statement not reached error in while() loop
while loop