wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Code not reachable 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 "Code not reachable" Watch "Code not reachable" New topic
Author

Code not reachable

Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
if(false){
i=10;
}
Why don't I get a "code not reachable" error. Please explain me.


SCJP 1.4<p>Wingardium Leviosa!!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Please read JLS 14.20 Unreachable Statements that explains issues about unreachable statements.


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

Joined: Oct 31, 2002
Posts: 108
Thanks!!
dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
because that the assignment to i can never be executed.


scjp 1.4<br />challenge haven't limit!
Don Bosco
Ranch Hand

Joined: Oct 31, 2002
Posts: 108
please read it correctly dragon. it is NOT GIVING "unreachable statement" error.
dragon ji
Ranch Hand

Joined: Oct 31, 2002
Posts: 110
yeah,you are right.sorry,I knew it a moment ago.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Note that if you change "if (false)" to "while (false)" the compiler WILL complain.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code not reachable