• 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

marcus green mock

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
the below code is from marcus green mock 1 -- i m not able to understand the out of this code.. it prints

value for i=1 value for j=1
value for i=2 value for j=2 please explain



public class MyFor{
public static void main(String argv[]){
int i;
int j;
outer:
for (i=1;i <3;i++)

inner:
for(j=1; j<3; j++)
{
if (j==2)
continue outer;
System.out.println("Value for i=" + i + " Value for j=" +j);
}

}

}
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
this code gives the below output.
value for i=1 value for j=1
value for i=2 value for j=1

if the value of j is equal to 2 it control moves to the outer loop,skipping the print statement.
 
reply
    Bookmark Topic Watch Topic
  • New Topic