Escape sequences in Java



A character preceded by a backslash (\) is an escape sequence and has a special meaning to the compiler.

The following table shows the Java escape sequences.

Escape SequenceDescription
\tInserts a tab in the text at this point.
\bInserts a backspace in the text at this point.

Inserts a newline in the text at this point.
\rInserts a carriage return in the text at this point.
\fInserts a form feed in the text at this point.
\'Inserts a single quote character in the text at this point.
\"Inserts a double quote character in the text at this point.
\Inserts a backslash character in the text at this point.

Let us see an example of Character Escape Sequences in Java.

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      char ch = '\u039A';
      System.out.println(ch);
   }
}

Output

K
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements