JAVA循环结合标签使用,控制跳转

时间:2022-10-19 04:32:29
public static void main(String[] args) {
outer: for (int i = 0; true; i++) {
inner: for (int j = 0; true; j++) {
System.out.println("i=" + i + "------j=" + j);
if (j == 1) {
System.out.println("continue");
continue;
} if (j == 4) {
System.out.println("continue outer");
continue outer;
} if (j == 6) {
System.out.println("break");
break;
} if (i == 2) {
if (j == 3) {
System.out.println("continue inner");
j++;
continue inner;
}
} if (i == 3) {
System.out.println("break outer");
break outer;
}
}
}
}