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.
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…
A Binary Search Tree (BST) is a type of binary tree that satisfies the following…