Win a copy of Microservices in Action this week in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

confused about labled break  RSS feed

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in exam watch :
Remember, continue statements must be inside a loop; otherwise,
you�ll get a compiler error. break statements must be used inside either a loop orswitch statement. (Note: this does not apply to labeled break statements.).

in another eexam watch:
"Labeled continue and break statements must be inside the loop that
has the same label name; otherwise, the code will not compile."

HOW come??? can anybody told me any explain about the first note??
class D{

public static void main(String [] ism){
int f=0;

for2:
for(int i=0;i<5;i++){
System.out.println("ffff");}
}


void fool(){
break for2;}
}


this is wont compile sure but ,why the first exam watch wrote "Note: this does not apply to labeled break statements.)"

thanks all
[ August 16, 2006: Message edited by: saied ims ]
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why label statement causes compile time error?:


If a break statement has a label it must be the label of an enclosing statement.



Here is an example:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!