Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in continue code

 
Randika Isuru
Ranch Hand
Posts: 38
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are correct. The compiler knows there is no way the code can get past that throw statement.
 
Randika Isuru
Ranch Hand
Posts: 38
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much Jeanne Boyarsky for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic