मराठी

Explain the Escape Sequences in Java.

Advertisements

प्रश्न

Explain the Escape Sequences in Java.

स्पष्ट करा
Advertisements

उत्तर

In Java, Escape Sequences are special character combinations used to represent characters that cannot be directly typed or displayed in a string. An escape sequence begins with a backslash (\) followed by a character. These sequences are mainly used to format text and control the output of a program.

The commonly used escape sequences in Java are as follows:

Escape Sequence

Description

\n

It is used to move the cursor to a new line.

\t

It is used to insert a horizontal tab space.

\b

It represents a backspace character.

\r

It is used to move the cursor to the beginning of the current line.

\f

It represents a form feed character.

\'

It is used to represent a single quotation mark.

\"

It is used to represent a double quotation mark.

\\

It is used to represent a backslash character.

Example:

System.out.println("Hello\nJava");

Output:

Hello
Java
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 5: Primitive Values, Wrapper Classes, Types and Casting - EXERCISE [पृष्ठ ११२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 5 Primitive Values, Wrapper Classes, Types and Casting
EXERCISE | Q 11. | पृष्ठ ११२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×