有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java理解问题系统。出来普林顿

我是编程新手,今天从Java开始。我正在阅读Robert Sedgewick和Kevin Wayne的在线版《Java编程入门》,并使用DrJava编辑器

有一个特别的练习让我想知道:

Modify UseArgument.java to make a program UseThree.java that takes three names and prints out a proper sentence with the names in the reverse of the order given, so that for example, "java UseThree Alice Bob Carol" gives "Hi Carol, Bob, and Alice.".

我的结果如下:

    public class UseThree {

    public static void main(String[] args) {
        System.out.print("Hi, ");
        System.out.print(args[2]);
        System.out.print(", ");
        System.out.print(args[1]);
        System.out.print(", and ");
        System.out.print(args[0]);
        System.out.println(".");
    }
}

现在,当我输入java UseThree Alice Bob Carol时,它说Hi, Carol, Bob, and Alice.

但我认为System.out.println打印的是新的一行

结果不应该是这样吗

Hi, Carol, Bob and Alice
.

我希望你能为我解释一下这个话题,我想从一开始就把事情做好。提前谢谢你

来自德国的问候

卡迪尔


共 (0) 个答案