Home > Java > JavaBase > body text

What is newline character in java

王林
Release: 2020-07-11 13:19:24
Original
26409 people have browsed it

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()
Copy after login

The second method:

System.out.print("\n");
Copy after login

(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")
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template