हिंदी

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 [पृष्ठ १३१]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 6 Variables and Expressions
EXERCISE | Q 29. (ii) | पृष्ठ १३१
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×