The Command.. break; in Java what if.?

后端 未结 8 479
走了就别回头了
走了就别回头了 2021-02-03 17:50

What if we have an if statement inside a for loop, would it stop the loop or the if condition...

Example:

for (int i = 0; i < array.length; i++) {
           


        
8条回答
  •  清歌不尽
    2021-02-03 18:17

    You can break out of just 'if' statement also, if you wish, it may make sense in such a scenario:

    for(int i = 0; i

    you can also break out of labeled {} statement:

    for(int i = 0; i

提交回复
热议问题