我遇到了一個在我的編程語句在Android中的麻煩,它不斷給我錯誤,標籤230丟失,但我不知道什麼是做錯了。任何幫助將不勝感激謝謝。返回和break語句錯誤
這是下面的程序;
public static void calculateGPA()
{
totalHours = 0.0D;
totalValue = 0.0D;
int i = 0;
if (i >= 8)
{
Object[] arrayOfObject = new Object[1];
arrayOfObject[0] = Double.valueOf(totalValue/totalHours);
GPA = String.format("%.2f", arrayOfObject);
if (!GPA.equals("NaN"))
break label230;
GPA = "0.00";
}
while (true)
{
return;
int j = collegeGradeSpinner[i].getSelectedItemPosition();
int k = collegeHourSpinner[i].getSelectedItemPosition();
if ((j != 0) && (k != 0))
switch (j)
{
default:
case 1:
case 2:
case 3:
case 4:
case 5:
}
while (true)
{
i++;
break;
totalValue += k * 4;
totalHours += k;
continue;
totalValue += k * 3;
totalHours += k;
continue;
totalValue += k * 2;
totalHours += k;
continue;
totalValue += k * 1;
totalHours += k;
continue;
totalHours += k;
}
label230: gpaTextView.setText(GPA);
}
}
你的標籤內部存在封閉塊實現自己的requriement。你不能「打破」這個塊:閱讀這個http://stackoverflow.com/questions/8802287/break-and-label-the-label-mylable-is-missing – Willmore
這個代碼是通過一個工具生成的,因爲那裏很多領域都可以在你的代碼中得到改進。例如GPA的分類可以簡單地進行如下GPA = String.toString(Math.round(totalValue/totalHours,2));根據你的要求,這可以做得更簡單 – asela38