Reputation: 127
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;
}
Upvotes: 0
Views: 222
Reputation: 4533
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;
}
Upvotes: 1
Reputation: 79807
Declare localObject1
as a List
instead of an Object
. That should fix this error.
Upvotes: 0
Reputation: 24820
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
Upvotes: 1