简体   繁体   English

此代码中的编译错误

[英]Compilation error in this code

Compilation error in this code , how can I fix this java code? 在这段代码中编译错误,我该如何修复这个java代码?

anyone know how to fix this? 有人知道怎么修这个东西吗? and the label284; label284; is giving some problem. 给了一些问题。

Pastebin : http://pastebin.com/gWKwnqg5 Pastebin: http//pastebin.com/gWKwnqg5

Image : http://i.imgur.com/OwbdR.png 图片: http//i.imgur.com/OwbdR.png

 private List<int[]> getDataByAverage()
  {
    int i = this.money;
    Object localObject1 = new ArrayList();
    if (this.num != 1)
    {
      for (int j = 0; j < this.num; j++)
        ((List)localObject1).add(new int[2]);
      i /= this.num;
      j = 0;
      int k = 0;
      while (k < this.num)
      {
        Object localObject2;
        if (k + 1 != this.num)
        {
          int n;
          if (10.0D * Math.random() <= 5.0D)
            n = 0;
          else
            n = 1;
          int m = (int)(Math.round(Math.random() * i) / 2L);
          localObject2 = (int[])((List)localObject1).get(k);
          if (n == 0)
            m = i - m;
          else
            m = i + m;
          localObject2[0] = m;
          j += ((int[])localObject1.get(k))[0];
        }
        else
        {
          localObject2 = new BigDecimal(String.valueOf(this.money));
          BigDecimal localBigDecimal = new BigDecimal(String.valueOf(j));
          ((int[])localObject1.get(k))[0] = ((BigDecimal)localObject2).subtract(localBigDecimal).intValue();
        }
        if (((int[])localObject1.get(k))[0] >= 0)
        {
          k++;
          continue;
        }
        localObject1 = getDataByAverage();
        break label284;
      }
      localObject1 = localObject1;
    }
    else
    {
      int[] arrayOfInt = new int[2];
      arrayOfInt[0] = this.money;
      ((List)localObject1).add(arrayOfInt);
      localObject1 = localObject1;
    }
    label284: return (List<int[]>)(List<int[]>)localObject1;
  }

I guess labeled break is used to get out of multiple for or while loops. 我猜标签中断用于退出多个for或while循环。 And you will have to declare the label above where you are using it. 您必须在上面的标签上声明您使用它的位置。 you can check here 你可以在这里查看

You will have to move label284: before it is used. 在使用之前,您必须移动label284:

Might well be a method to declare a label which i am not aware of 很可能是一种声明我不知道的标签的方法

Edit : Here's the method, put braces across the whole if (this.num != 1) else { } routine. 编辑 :这是方法,在整个if (this.num != 1) else { }例程中添加括号。 Then define label284: before it. 然后在它之前定义label284: Apparently the break label will goto end of statement. 显然,break标签将转到声明的结尾。 For more details check here 有关详细信息,请点击此处

try: 尝试:

 private List<int[]> getDataByAverage()
    {
        int i = this.money;
        Object localObject1 = new ArrayList();
        if (this.num != 1)
        {
            for (int j = 0; j < this.num; j++)
                ((List)localObject1).add(new int[2]);
            i /= this.num;
            j = 0;
            int k = 0;
            Object localObject2;
                if (k + 1 != this.num)
                {
                    int n;
                    if (10.0D * Math.random() <= 5.0D)
                        n = 0;
                    else
                        n = 1;
                    int m = (int)(Math.round(Math.random() * i) / 2L);
                    localObject2 = (int[])((List)localObject1).get(k);
                    if (n == 0)
                        m = i - m;
                    else
                        m = i + m;
                    localObject2= m;
                    j += ((int[])((List<int[]>) localObject1).get(k))[0];
                }
                else
                {
                    localObject2 = new BigDecimal(String.valueOf(this.money));
                    BigDecimal localBigDecimal = new BigDecimal(String.valueOf(j));
                    ((int[])((List<int[]>) localObject1).get(k))[0] = ((BigDecimal)localObject2).subtract(localBigDecimal).intValue();
                }
                if (((int[])((List<int[]>) localObject1).get(k))[0] >= 0)
                {
                    k++;

                }
                localObject1 = getDataByAverage();

            localObject1 = localObject1;
        }
        else
        {
            int[] arrayOfInt = new int[2];
            arrayOfInt[0] = this.money;
            ((List)localObject1).add(arrayOfInt);
            localObject1 = localObject1;
        }
        return (List<int[]>)(List<int[]>)localObject1;
    }

Declare localObject1 as a List instead of an Object . localObject1声明为List而不是Object That should fix this error. 这应该可以解决这个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM