Beginner Java Code not working - While loop error
I have an error in the while loop. The While Statement is showing as an error in Eclipse? What am I missing... (Yes I know it is simple code... I am going to start with beginner code first.
/**
* @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.");
开发者_如何学Python 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.");
}
}
}
}
The W in "while" should not be capitalized. I think that is all.
while
should be in lower case.... and "diet coke" should be "beer"...
精彩评论