【发布时间】:2015-02-07 10:48:01
【问题描述】:
在 java 代码的标签中使用 break 语句时出现错误。这显示undefined label。写这样的代码是错误的。请帮助我正确使用它。提前致谢。
while (true)
{
label149: if (!localIterator2.hasNext());
while (true)
{
i++;
break;
HashMap localHashMap2 = (HashMap)localIterator2.next();
if (!((String)localHashMap1.get("name")).equalsIgnoreCase((String)localHashMap2.get("emotion")))
break label149;
if (!((String)localHashMap2.get("IS_paid")).equalsIgnoreCase("1"))
break label246;
((HashMap)Saved.this.keynamedata.get(i)).put("is_paid", "1");
}
label246: ((HashMap)Saved.this.keynamedata.get(i)).put("is_paid", "0");
}
【问题讨论】:
-
呃,你的第一个 if... 后面多了一个分号
-
基本上,它们不是可怕、可怕、可怕的编程方式,而且是非常糟糕设计的重要指标
-
@fge - 谢谢你 :) 但删除它得到另一个错误
-
我完全不同意。标签是限制变量范围的好方法 - 重构其他人的懒惰编码的垫脚石。变量的作用域越受限制,代码就越容易理解。