适用于内层while循环中的产生的某个条件依赖于外部的for循环
例子如下
public class Test {
public static void main(String[] args) throws InterruptedException {
Random rand = new Random();
int[] str = {1,2,3,4};
for(int i=0;i<str.length;i++){
System.out.println("跳出while循环"+str[i]);
E:while(true){
Thread.sleep(2000);
int j = rand.nextInt(str[i]+1);
System.out.println("j"+j);
switch (j) {
case 1:
System.out.println(str[i]);
break E;
case 2:
System.out.println(str[i]);
break;
case 3:
System.out.println(str[i]);
break E;
default:
break;
}
}
}
}
}