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 Sequence | Description |
|---|---|
| \t | Inserts a tab in the text at this point. |
| \b | Inserts a backspace in the text at this point. |
| \n | Inserts a newline in the text at this point. |
| \r | Inserts a carriage return in the text at this point. |
| \f | Inserts 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
public class Demo { public static void main(String[] args) { char ch = '\u039A'; System.out.println(ch); } }
Output
K
Comments
Post a Comment