How to create a new line in Java output?

In Java, there are several ways to achieve line breaks when printing output.

  1. Can you please reword this sentence for me?
  2. Please provide a single option for paraphrasing the following text natively in English.
System.out.println("第一行\n第二行");

The output result:

第一行
第二行
  1. Prints to the console.
  2. display the output
System.out.println("第一行");
System.out.println("第二行");

Output:

第一行
第二行
  1. Print to the console.
  2. Output the information
System.out.print("第一行");
System.out.print("\n");
System.out.print("第二行");

Output result:

第一行
第二行

It should be noted that the above methods are all for console output. If you are outputting in a file, you can use System.getProperty(“line.separator”) to obtain the system’s default line separator.

bannerAds