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 Labels ...... 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 "Labels ......" Watch "Labels ......" New topic
Author

Labels ......

meeta verma
Greenhorn

Joined: May 15, 2004
Posts: 19

Why this gives a compilation error? Is continue to be used only with for and while.
(code tags added)

[ May 24, 2004: Message edited by: Barry Gaunt ]
[ May 24, 2004: Message edited by: Barry Gaunt ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Well the compilation error is:


And the Java Language Specification says:

If no while, do, or for statement of the immediately enclosing method or initializer block encloses the continue statement, a compile-time error occurs.

[ May 24, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
in other words, labels can ONLY be used in conjunction with loops.



is therefore illegal code in Java.



is legal if not exactly good coding style


42
Wendal Park
Ranch Hand

Joined: Aug 28, 2001
Posts: 39
Yes, using labels referred to loops is legal in Java. You may hence think it's not the usual coding style. However, for labels that are used in nested loops scenario, it may give you a better idea about the true value of using labels. It gives an alternative to manipulating a couple of indices in a program (which make code less readable).


MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Labels ......
 
Similar Threads
Assigning log4j log levels to logging "business" information
unexpected output
Question (implicit conversion)
Scjp cracked @88%
For loop