適用於內層while循環中的產生的某個條件依賴於外部的for循環dom
例子以下it
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;
}
}
}
}
}io