Java allows us to have certain non-graphic characters in character constants. (non-graphic characters are those which cannot be typed directly from the keyboard, e.g, backspace, tabs, carriage return, etc.). These characters are represented with the use of an escape sequence, which is represented by a backslash(\) followed by one or more characters.
The following table gives a listing of escape sequences:
Escape Characters | Description |
---|---|
\t | to insert a tab in the text at this point. |
\’ | to insert a single quote character in the text at this point. |
\” | to insert a double quote character in the text at this point. |
\r | to insert a carriage return in the text at this point. |
\\ | to insert a backslash character in the text at this point. |
\n | to insert a new line in the text at this point. |
\f | to insert a form feed in the text at this point. |
\b | to insert a backspace in the text at this point. |
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!\r\"Coderzpy\" ");
}
}
Hello, world!
"Coderzpy"
Note: also read about the Literals in Java
If you like my post please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
You are given a stream of elements that is too large to fit into memory.…
The formula for the area of a circle is given by πr². Use the Monte…
Given an integer k and a string s, write a function to determine the length…
There is a staircase with N steps, and you can ascend either 1 step or…
Build an autocomplete system that, given a query string s and a set of possible…
Design a job scheduler that accepts a function f and an integer n. The scheduler…