Home > Java > javaTutorial > body text

What character is carriage return in java?

下次还敢
Release: 2024-04-21 02:43:03
Original
659 people have browsed it

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>
Copy after login
Output :

<code>HelloWorld!</code>
Copy after login
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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!