标签不能像这样工作。在Java中,没有任何
gotolabel功能。当您有内部循环且需要
break或
continue有外部循环时,将使用标签,如以下示例所示:
outterloop:for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { // this would break the inner loop and go to the next outter loop iteration // break; // this would break the outter loop, thus exiting both loops // break outterloop; // this would jump to the next inner loop iteration // continue; // this would jump to the next outter loop iteration, exiting the inner loop // continue outterloop; }}您需要的是在不使用标签的情况下改进代码结构以实现所需的功能。
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html



