Explain the following with an example segment: Escape Character
Advertisements
प्रश्न
Explain the following with an example segment:
Escape Character
कोड लेखन
स्पष्ट करा
Advertisements
उत्तर
- An Escape Character in Java is a backslash (
\) used with another character to represent special characters that cannot be directly written in a string. - Escape sequences are used to insert special characters such as a new line (
\n), tab space (\t) and double quotation marks (\").
Example Code Segment:
System.out.println("Hello\nWorld");
System.out.println("Java\tProgramming");
System.out.println("Welcome to \"Java\"");
Output:
Hello World Java Programming Welcome to "Java"shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]
