我在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