0

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 : https://i.sstatic.net/xM1St.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;
  }
4
  • 1
    It helps a lot if you tell us what the error is. Commented Jan 13, 2012 at 8:26
  • here's the image : i.imgur.com/OwbdR.png Commented Jan 13, 2012 at 8:29
  • ArrayList doesn't mean it's list of arrays, it means that it is a list backed by array. why ain't your localObejct1 of type List<Integer[]>? Commented Jan 13, 2012 at 9:02
  • And also break is not goto command! Commented Jan 13, 2012 at 9:04

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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;
    }

Comments

0

Declare localObject1 as a List instead of an Object. That should fix this error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.