相关疑难解决方法(0)

打破嵌套循环和主循环

我有以下代码:

int x = 100; //Or some other value

while(x > 0) {

    for(int i = 5; i > 0; i++) {

        x = x-2;

        if(x == 0)
            break;

        }

}
Run Code Online (Sandbox Code Playgroud)

但是,这只会打破for循环.我怎样才能打破for和while循环呢?

干杯!

java for-loop while-loop

8
推荐指数
1
解决办法
520
查看次数

标签 统计

for-loop ×1

java ×1

while-loop ×1