Home >Java >JavaBase >What is newline character in java

What is newline character in java

王林
王林Original
2020-07-11 13:19:2426477browse

The newline characters in java are [\n] and [\r]. The difference between the two is: [\r] means carriage return, [\n] means new line, but both can achieve line breaks. The specific implementation method is: [System.out.print("\n")].

What is newline character in java

#In java, you can use \n and \r for line breaks.

(Recommended tutorial: java entry program)

The difference between the two is as follows:
1, \r Enter

2, \ n New line

The same thing between the two is: they will cause line breaks.

Commonly used line wrapping methods:

The first method:

System.out.println()

The second method:

System.out.print("\n");

(Video tutorial recommendation: java video tutorial)

Related introduction:

The newline character of the windows platform is/r/n;

The newline character of the linux platform is/n;

The java program will convert the newline characters entered by users on different platforms into the newline characters of a specific system.

You can get the newline character of the current system through the following command:

System.getProperty("line.separator")

The above is the detailed content of What is newline character in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn