我在while循環中有錯誤。 While語句在Eclipse中顯示爲錯誤?我在想什麼......(是的,我知道這是簡單的代碼...我要開始初學者代碼第一。初學Java代碼不工作 - 雖然循環錯誤
/**
* @author Nathan
*
*/
public class DietCokeSong {
/**
* @param args
*/
public static void main(String[] args) {
int dietCokeNum = 99;
String word = "Cans of Diet Coke";
While(dietCokeNum > 0) {
System.out.println(dietCokeNum + " " + word + " on the wall");
System.out.println(dietCokeNum + " " + word + ".");
System.out.println("Take one down.");
System.out.println("Pass it around.");
dietCokeNum = dietCokeNum - 1;
if(dietCokeNum > 0) {
System.out.println(dietCokeNum + " " + word + " on the wall");
} else {
System.out.println("No more Cans of Diet Coke on the wall.");
}
}
}
}
雖然這是一個相當瑣碎,在你未來的問題,你應該總是copypaste的**精確的**錯誤/異常消息和堆棧跟蹤,而不是用「一個錯誤」來概括它,它包含了你的問題的答案,你只需要找到能夠以外行的條件爲你翻譯它的人。 – BalusC