0
我曾嘗試在牆上製作一瓶啤酒,這是很多人的基本習慣。瓶啤酒
這是我的,但我不明白爲什麼我沒有得到任何輸出?
任何幫助,將不勝感激。由於
public class PeopleInARoom
{
public static void main(String[] args) {
int humanNum = 10;
String word = "people";
while (humanNum < 0) {
if (humanNum == 1) {
word = "person"; //singular, as in one person.
}
System.out.println(humanNum + " " + word + "people in a room");
System.out.println("Wait...somebody left!");
humanNum = humanNum - 1;
if (humanNum > 0) {
System.out.println(humanNum + " " + word + "people in a room");
} else {
System.out.println("Hey, where has everybody gone?");
}
}
}
}
'int human = 10','while(humanNum <0)',只是一點提示;) – SomeJavaGuy
humanNum被聲明爲10,但是while循環不會被應用,因爲它大於0。只會在humanNum小於0時執行。 – Sky
while(humanNum> 0) – Sky