Home  >  Article  >  Java  >  What character is carriage return in java?

What character is carriage return in java?

下次还敢
下次还敢Original
2024-04-21 02:43:03646browse

The carriage return character in Java is \r. It indicates that the cursor moves to the beginning of the line, usually used with the newline character \n, which moves the cursor to the next line and back to the beginning of the line.

What character is carriage return in java?

The carriage return character in Java

In Java, the carriage return character is \r.

Details

The carriage return character is a control character indicating that the cursor should move to the beginning of the line. It is usually used with a newline character (\n) to move the cursor to the next line and back to the beginning of the line.

  • \r: Carriage return character
  • \n: Line feed character

## Example

The following code example demonstrates how to use

\r and \n to print text to a new line:

<code class="java">System.out.println("Hello\r\nWorld!");</code>
Output :

<code>HelloWorld!</code>
Note that

\r moves the cursor back to the beginning of the line, while \n moves the cursor to the next line.

The above is the detailed content of What character is carriage return 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