• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

label ->Continue

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Code1 :
-----
outer:
for( i=0; i<10; i++ ){<br /> for( j=10; j>0; j--) {
if( j== 5 ) {
continue outer; // next iteration of i
}
}
}
When at j ==5 , control goes to label outer ,
were the value of J and I kept ?

Output: 10 5
Code2:
-----
outer:
for( i=0; i<10; i++ ){<br /> for( j=10; j>0; j--) {
if( j== 5 ) {
break outer; // next iteration of i
}
}
}
When at j ==5 , control goes to label outer ,
were the value of J and I was NOT kept , right ?

Output: 0 5
Thanks
ML
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In both cases i's value is kept but j enters with value 0 again due to inner for loop.

------------------
azaman
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tsk tsk tsk
Read the question more carefully,
In both cases I retains it's value...
and J is reset to the value of 10.
Eric
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic