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 label continue 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 "label continue" Watch "label continue" New topic
Author

label continue

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Code from whizlabs. Why am I getting compilation error "The label signal is missing" I tried to change as given below but kicked out with "continue cannot be used outside of a loop". Not sure what is happening
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40


The continue statement can only be used for loops -- so with a labelled continue, the label must target a loop.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Did you mean to say continue is for "for loop" and not for "if loop" ?
Henry Wong wrote:
The continue statement can only be used for loops -- so with a labelled continue, the label must target a loop.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

Saibabaa Pragada wrote:Did you mean to say continue is for "for loop" and not for "if loop" ?



There is no such a thing as a "if loop". "if" statements are not loops.

Henry
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
My mistake..Thanks for correcting..Let me change my sentence..Did you mean to say continue keyword is applicable for "for loop" only and not for "if statement" ? Please advice if this statement is right.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19064
    
  40

Saibabaa Pragada wrote:My mistake..Thanks for correcting..Let me change my sentence..Did you mean to say continue keyword is applicable for "for loop" only and not for "if statement" ? Please advice if this statement is right.


The continue statement may be used for any loop. The while loop, do-while loop, and both variants of the for loop.

Henry
Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Great..Thanks Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: label continue