Joke Collection Website - Public benefit messages - Differences between Java string newlines "\n", "r" and "\r\n"

Differences between Java string newlines "\n", "r" and "\r\n"

1.

\n

Represents the new

Line, that is, newline character

2.

\r

Representative carriage

Return means to go back to the beginning of the line without moving to the next line.

3.

\r\n

Enter a new line, that is, go back to the beginning of the line and change a line.

It has different meanings in different systems.

Meaning in windows:

\n '

Line feed to the next line at the current position without returning to the beginning of the line;

\r

It means to go back to the beginning of a line without moving to the next line.

Meaning in linux:

\n Enter+ line feed operation will be performed.

\r

The carriage return character will only be displayed as the control character ("M"), and the carriage return operation will not occur.

Finally, in the system, it means carriage return and line feed.