Java 以下代码的输出错误

Java 以下代码的输出错误,java,Java,这个代码的输出应该从99开始,但它从59开始。原因是什么? 这是密码 public class BeerSong { public static void main(String[] args) { int x = 99; String word = "bottles"; while (x > 0) { if (x == 1) { word = "bottle"; // sing

这个代码的输出应该从99开始,但它从59开始。原因是什么? 这是密码

public class BeerSong {
    public static void main(String[] args) {
        int x = 99;
        String word = "bottles";
        while (x > 0) {
            if (x == 1) {
                word = "bottle"; // singular, as in ONE bottle.
            }
            System.out.println(x + "" + word + " of beer on the wall");
            System.out.println(x + "" + word + " of beer.");
            System.out.println("Take one down.");
            System.out.println("Pass it around.");
            x = x - 1;
            if (x > 0) {
                System.out.println(x + "" + word + " of beer2 on the wall");
            } else {
                System.out.println("No more bottles of beer on the wall");
            } // end else
        } // end while loop
    } // end main method
} // end class

我认为达伍德已经给出了最合理的答案。您的输出窗口有限。我刚刚在Linux提示符下执行了您的代码,当我向上滚动完成时,它实际上从99开始


您的控制台显示的行数是否有限制?也许这首歌的某些部分已经从顶部滚动了下来。它在netbeans中运行正常,但在命令提示符下运行不正常