This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Unreachable statements" Watch "Unreachable statements" New topic

Unreachable statements

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442

The above code compiles & runs fine.
Shouldn't th above code give complier error that "Unreachable statement"?Co line 1 is never reached What are the scenarios when compiler throws unreachable statement error?Are these kind of questions ,where compiler gives error that"Unreachable statement" going to appear in the exam?

"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
Method m1() might throw an exception that would halt the program as opposed to having a straight statement like throw new Exception(); A call to a method throwing an exception shouldn't make a statement immediately after it unreachable. Don't forget, m1() can be overridden not to throw any exception.
wood burning stoves
subject: Unreachable statements
It's not a secret anymore!