June 2012
Intermediate to advanced
288 pages
6h 48m
English
Escape Sequences
String and character literals can use special escape sequences to represent special characters or symbols.
|
Escape Sequence |
Explanation |
|
|
Backspace |
|
|
Horizontal tab |
|
|
New line |
|
|
Form feed |
|
|
Carriage return |
|
|
Double quote |
|
|
Single quote |
|
|
Backslash |
For example, here is a statement that displays two lines of text on the console:
System.out.println(“Hello\nWorld!”);
In this example, a new line character (\n) is inserted between the words Hello and World!. The resulting output will look like this:
Hello
World!
Read now
Unlock full access