</pre> direct with break; the details are as follows: <p></p><p></p><p></p><pre name= "Code" class = "java" ><span style= "font-size:18px;" >package Com.test;public class Test {public static void main (string[] args) {for (int i=0;i<5;i++) { for (int j=0;j<i;j++) {System.out.println ("i=" +i+ "j=" +j); }}}}</span>
Output Result: I=1 j=0
i=2 j=0
i=2 j=1
I=3 j=0
I=3 j=1
I=3 j=2
I=4 j=0
I=4 j=1
I=4 j=2
I=4 j=3
Now make a slight change to the code. Implementation jumps out of multiple loops.
<span style= "FONT-SIZE:18PX;" >public class Test {public static void main (string[] args) {outer:for (int i=0;i<5;i++) { for (int j=0;j<i;j++) {System.out.println ("i=" +i+ "j=" +j); Break outer; } } }}</span>
Output Result: I=1 j=0
That is, the System.out.println is executed once ("i=" +i+ "j=" +j);
Jumps out of this multiple loop. There are two changes: 1. Add tag to loop: outer 2.break outer;
Complete.
In Java, how do you jump out of the current multi-loop?