[英]Beginner Java Code not working - While loop error
我在while循環中有一個錯誤。 While語句在Eclipse中顯示為錯誤? 我缺少什么...(是的,我知道這是簡單的代碼...我將首先從初學者代碼開始。
/**
* @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.");
}
}
}
}
“ while”中的W不應大寫。 我認為僅此而已。
while
應使用小寫字母...而“飲食可樂”應使用“啤酒” ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.