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

unreachable try{

Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531


compile error: unreachable statement try{

but why do i get this?
if there was not a throw statement just after the try block then isnt case 2 and case 3 unreachable statement as they are never reach as x is 1
Linda Wiklund
Greenhorn

Joined: Oct 22, 2009
Posts: 11
on line 10 you throw an exception, hence, JVM will exit the method. the try-statement on line 11 will NEVER be reached.
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
i know that....but what is there to give an error in this?
Linda Wiklund
Greenhorn

Joined: Oct 22, 2009
Posts: 11
Code that never will be reached, never used is redundant. It should not bee there. You'll get the same error if you have code after a return statement.
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
Thanks I will keep that in my mind as long as possible......
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unreachable try{