java中如何让输出结果换行
在Java中,可使用
还是
来表示换行。例如:
System.out.println("Hello World!");
System.out.println("This is a new line.");
输出:
Hello World!
This is a new line.
还是使用System.out.print()
方法,然后在需要换行的地方使用System.out.println()
方法。例如:
System.out.print("Hello World!");
System.out.println("This is a new line.");
输出:
Hello World!This is a new line.
注意:在Windows环境下,使用的换行符是
,在Unix环境下,使用的换行符是
。在大部份操作系统中,Java会根据运行环境自动选择正确的换行符。
TOP