简体   繁体   中英

Compilation error in this code

Compilation error in this code , how can I fix this java code?

anyone know how to fix this? and the label284; is giving some problem.

Pastebin : http://pastebin.com/gWKwnqg5

Image : 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. 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.

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. Then define label284: before it. Apparently the break label will goto end of statement. 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 . That should fix this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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