• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

for loops

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

hi everybody,
i am very confusing about this for loops.
please tell me the output of this.if possibel
please exaplian about what is continue outer,
break,continue.
thanks.
outer: for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
if (i == j) {
continue outer;
}
System.out.println("i = " + i + " j = " + j);
}
}
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Teja,

Lemme try to explain this...
outer: for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
if (i == j) {
continue outer;
}
System.out.println("i = " + i + " j = " + j);
}
}
In this code, When the compiler encounters "continue outer" for the first time, would be when 1= 0 & j = 0. Then instead of continuing the the second loop the control jumps to the first loop to continue processing ... & so on
Thx
Aruna
reply
    Bookmark Topic Watch Topic
  • New Topic