Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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!