初学者Java代码无法正常工作 - 循环错误

时间:2011-10-03 22:41:32

标签: java

我在while循环中有错误。 Eclipse语句在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.");
        }
    }
}
}

2 个答案:

答案 0 :(得分:8)

“while”中的W不应该大写。我认为就是这样。

答案 1 :(得分:3)

while应该是小写的......而“节食可乐”应该是“啤酒”......

相关问题