File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problem in continue code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problem in continue code" Watch "Problem in continue code" New topic
Author

Problem in continue code

Randika Isuru
Ranch Hand

Joined: Sep 15, 2013
Posts: 34

Hi all,
can any one tell me why below code give an error. i need a reason for that..



This is the error Terminal gives to me


isuru@isuru-System-Product-Name:~/Java OCPJP/Flow Control, Exception, and Assertions/Untitled Folder 5$ javac TryCatchKeyword.java
TryCatchKeyword.java:12: error: unreachable statement
System.out.println("after exception throw");
^
1 error




i think this error occurred because i used throw keyword JVM knows the when throw keyword used code written after that keyword are not executed that why is give me an error "error: unreachable statement" am i correct?
please any one can help me

Thanks.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Yes, you are correct. The compiler knows there is no way the code can get past that throw statement.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Randika Isuru
Ranch Hand

Joined: Sep 15, 2013
Posts: 34

thank you very much Jeanne Boyarsky for your help
 
 
subject: Problem in continue code
 
Similar Threads
What is dead code?
Why is this not a compilation error?
code not reachable error
Problem in Exception
Unreachable statement