我編寫了一個簡單的 for while 循環程序,編輯器窗口沒有顯示錯誤,但是當我運行程序時,控制臺沒有顯示任何輸出。我已經調整了控制臺首選項,切換了限制控制臺輸出和固定寬度控制臺選項,我還嘗試將輸出更改為系統上另一個位置的日志文件。public class whileLoop {public static void main(String[] args) {int x = 10;while (x < 20);{System.out.print("Value of X is: " + x);x++;System.out.print("\n");}}}預期結果應為: x 的值為 10 x 的值為 11 x 的值為 12 x 的值為 13 ...但是我沒有任何東西顯示在屏幕上。
1 回答

aluckdog
TA貢獻1847條經驗 獲得超7個贊
;您在代碼中添加了額外內容。嘗試這個:
public class whileLoop {
public static void main(String[] args) {
int x = 10;
while (x < 20) {
System.out.print("Value of X is: " + x);
x++;
System.out.print("\n");
}
}
}
添加回答
舉報
0/150
提交
取消