Java "The label Label244 is missing"错误

标签 java eclipse

我在错误列表中看到此错误,但似乎无法找到解决方法。我尝试的一切似乎都没有效果。

  if (this.mouseX >= 522 + paddingX + (clientSize >= 1 ? 3 - (this.longTabs ? 240 : 0) : 0)) {
    if (this.mouseX <= 762 + paddingX + (clientSize >= 1 ? 3 - (this.longTabs ? 240 : 0) : 0)) {
      if (this.mouseY >= '©' + (clientSize >= 1 ? 261 + (this.longTabs ? 37 : 0) : 0) + paddingY) {
        if (this.mouseY < '�' + (clientSize >= 1 ? 261 + (this.longTabs ? 37 : 0) : 0) + paddingY) {
          break label244; } //Where the error is
        }
      }
    }
  }

但是这里设置了label244:

        {
          int i;
          label244: i = 0;
          for (int x = 0; i < 8; x += 30)
          {

能否通过一些示例告诉我如何解决这些问题?我还剩下 17 个这样的错误。

最佳答案

来自Java Language Specification #14.7 (强调我的)

[...] Java programming language has no goto statement; identifier statement labels are used with break (§14.15) or continue (§14.16) statements appearing anywhere within the labeled statement.

The scope of a label of a labeled statement is the immediately contained Statement.

这意味着标签

label244: i = 0;

仅影响i=0。换句话说,它类似于

label244: {
    //here you can use label
    i = 0;
}
//but here label is no longer accessible.

因此在此范围之外它不可见/不可访问。

如果您想在 for 范围内使用它,请将其放在它之前(将其移到 i = 0; 之后)。

int i;
i = 0;
label244: 
for (int x = 0; i < 8; x += 30)
{
    //...
}

关于Java "The label Label244 is missing"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23963218/

相关文章:

android - 如何消除android layout.xml中的warning : "missing contentDescription"

java - 在 eclipse 中多次运行相同的运行配置

eclipse - 第谷编译器未从插件依赖项中找到类

java - 如何为 java spring maven 应用程序映射域?

java - 秒表错误,求助!! - java.lang.NumberFormatException : Invalid int: "0:00"

java - 这会导致堆栈溢出错误吗?

java - 根据当前文本压缩修订历史记录

Android - 图书馆项目

java - 升级到 2021-06 (4.20.0) 后,Eclipse 内容辅助循环失败

java - 使用 springboot 和 hibernate 从 mysql 数据库检索日志数据的问题