System.out.print("I have a question, can you assist me?");
System.out.println();
System.out.println("How can I make a gap between these two statements?");


我尝试使用println(),以为会创建空白行,但没有。

最佳答案

尝试:

public class Main {

    public static void main(String args[]) {
        System.out.println("I have a question, can you assist me?\n");
        System.out.println("How can I make a gap between these two statements?");
    }
}


附言\n是换行符,至少在Windows计算机上可以正常运行。要实现真正的跨平台分隔符,请使用以下方法之一:

System.out.print("Hello" + System.lineSeparator()); // (for Java 1.7 and 1.8)
System.out.print("Hello" + System.getProperty("line.separator")); // (Java 1.6 and below)

10-07 18:58
查看更多