[英]If I have if() statements nested in a for() loop, does a break; within them apply to the for() loop? [duplicate]
除了标题中提供的问题外,没有其他内容...
例:
for(...) {
if(...) {
if(...) {
//doing stuffs
break;
}
}
}
//does that break statement get me to this spot?
在这种情况下,它将脱离for
循环。 break
将中断循环(例如while
, do/while
, for
)和switch
语句。
是。 break
将打破for循环。 break
不会脱离if语句。
是。 因为break
对于if
语句不起作用。 因此,它将适用于遇到的下一个循环。
注意: break
用于终止循环( for
, while
或do-while
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.