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.
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>
<code>HelloWorld!</code>
\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!