查查知识网

continue continue翻译成中文

发布者:张俊
导读public class TestBreak { public static void main { while (tr

public class TestBreak {

public static void main(String[] args) {

while (true){

//条件为true导致无限循环

int i = (int)(Math.random()*101);

//循环内定义的变量退出循环后消失

System.out.println(i);

if (i==88){

break;

//遇到break会强制退出循环,死循环中止

}

}

int count = 0;

for(int i = 100;i<=150;i++){

if(i%3==0)continue;

System.out.print(i+&34; &34;);

count++;

if(count%5==0){

System.out.println();

}

}

System.out.println();

outer:for (int i = 100;i<=150;i++){

//跳转用outer 带标签的coutinue

for(int j = 2;j

if (i%j==0){

continue outer;

//回到outer行 进行下一个循环

}

}

System.out.print(i+&34; &34;);

}

System.out.println();

count = 0;

for (int i = 100;i<=150;i++){

for (int j = 2;i>=j*j;j++){

if (i%j==0){

count = 1;

break;

//break会强制退出当前循环,这里会回到上一层循环继续

}

}

if (count==0){

System.out.print(i+&34; &34;);

}

count = 0;

}

}

}