In Java, how does break interact with nested loops?

后端 未结 4 2105
攒了一身酷
攒了一身酷 2020-12-23 21:32

I know a break statement jumps out of a loop, but does it jump out of nested loops or just the one its currently in?

4条回答
  •  难免孤独
    2020-12-23 22:05

    By default, it jumps out of the innermost loop. But you can specify labels and make it jump of outer loops too.

提交回复
热议问题