為什么我的條件為i==6沒有輸出值
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
int i = 1; // 代表 1 - 5 之間的數(shù)字
? ? ? ??
// 當變量小于等于 5 時執(zhí)行循環(huán)
while (i==6? ? ? ?) {
? ? ? ? ? ??
// 輸出變量的值,并且對變量加 1,以便于進行下次循環(huán)條件判斷
System.out.println(i);
i++;
}
}
}
2019-07-03
你while后面循環(huán)條件有問題,剛開始時i=1,不等于6,while后面的循環(huán)條件判斷為false,就不執(zhí)行while里面的代碼了;你應該把循環(huán)條件改為while(i<=5)
2019-07-29
因為你直接把全員變量和while內(nèi)容參數(shù)做比較啦;while就會自動認為false;
2019-07-19
while(i<=5)? while(i<6) 都可以,while(i==6)不是判斷語句
2019-07-12
while( i < 6)