File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Problem in Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Problem in Exception" Watch "Problem in Exception" New topic
Author

Problem in Exception

Irfan Zubair
Greenhorn

Joined: Jun 12, 2012
Posts: 17


I don't know why I am getting this error.

MyClass.java:6: unreachable statement
System.out.println("2");
^
1 error

Can anyone tell me why?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9947
    
    6

first, let's format this correctly:


Now...how exactly do you think you can reach line 9? As soon as you throw the exception on line 8, you jump to the finally block on line 11. So there is no possible way for this line to execute. The compiler can tell, and assumes that you made a mistake somewhere.


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in Exception
 
Similar Threads
about try and finally
explain try catch problem
Overriden exception
unreachable code
Exception error