for loops

if i have two for loops like below, how would i get the inner loop to stop executing, but the other one to keep on going? for example if i wanted the output:

0 0

0 1

0 2

1 0

1 1

1 2

2// the inner loops stops here

3

4

etc

for (int i = 0; i <6; i++)

{

for (int x = 0; x <3; x++)

{

System.out.println(i+" "+x);

}

}

[687 byte] By [mark_8206a] at [2007-11-26 19:10:04]
# 1
Add an if statement to the body of the inner loop, and only print x if i is less than some number.Kaj
kajbja at 2007-7-9 21:05:38 > top of Java-index,Java Essentials,New To Java...
# 2

for (int i = 0; i <6; i++)

{

for (int x = 0; x <3 && i < 2; x++)

{

System.out.println(i + " " + x);

}

if(i>=2)

System.out.println(i);

}

~Tim

SomeoneElsea at 2007-7-9 21:05:38 > top of Java-index,Java Essentials,New To Java...
# 3
ok thanks
mark_8206a at 2007-7-9 21:05:38 > top of Java-index,Java Essentials,New To Java...