错误:未定义标签,如何在Java中的此代码中使用label语句? [英] error:undefined label, how to use label statement in this code in java?
本文介绍了错误:未定义标签,如何在Java中的此代码中使用label语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Java教科书中读到,任何语句都可以标记并且可以与break一起使用. 但是,在尝试这段代码时,我得到了错误的未定义标签. (stackoverflow的家伙在将该问题标记为重复之前等待,我已经检查了这些问题,但没有一个解释这个问题.)
I read in textbooks for Java that any statement can be labeled and can be used with break. But while trying this code i get error undefined label. (Guys at stackoverflow wait before marking this question as duplicate, i have checked those questions but none of those explain this problem).
public class LabelTest {
public static void main(String[] args) {
first: System.out.println("First statement");
for (int i = 0; i < 2; i++) {
System.out.println("Second statement");
break first;
}
}
}
推荐答案
查看全文