如何前往下方的标签?

如何前往下方的标签?,第1张

如何前往下方的标签

标签不能像这样工作。在Java中,没有任何

gotolabel
功能。当您有内部循环且需要
break
continue
有外部循环时,将使用标签,如以下示例所示:

outterloop:for (int i = 0; i < 10; i++) {    for (int j = 0; j < 10; j++) {        // this would break the inner loop and go to the next outter loop iteration        // break;        // this would break the outter loop, thus exiting both loops        // break outterloop;        // this would jump to the next inner loop iteration        // continue;        // this would jump to the next outter loop iteration, exiting the inner loop        // continue outterloop;     }}

您需要的是在不使用标签的情况下改进代码结构以实现所需的功能。


https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5016976.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-15
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存