在新行中打印,java [英] Print in new line, java
本文介绍了在新行中打印,java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
System.out.println(" | 1 2 3 4 5 6 7 8 9");
System.out.println("----------------------------");
System.out.println("");
我使用println创建一个新行。是否可以使用\\\
或\r做同样的事情?
我试图将\ n添加到第二个println语句并继续使用print方法打印但是\ n不会创建新行。
I use println to create a new line. Is it possible to do the same using \n or \r? I tried to add \n to the second println statment and continue printing with the print method but \n does not create a new line.
任何想法?
推荐答案
String newLine = System.getProperty("line.separator");//This will retrieve line separator dependent on OS.
System.out.println("line 1" + newLine + "line2");
这篇关于在新行中打印,java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文