Meaningless Drivel is fun!
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Problem in continue code" Watch "Problem in continue code" New topic

Problem in continue code

Randika Isuru
Ranch Hand

Joined: Sep 15, 2013
Posts: 38

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 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

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

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

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Randika Isuru
Ranch Hand

Joined: Sep 15, 2013
Posts: 38

thank you very much Jeanne Boyarsky for your help
I agree. Here's the link:
subject: Problem in continue code
It's not a secret anymore!