Character Escape Sequence in Java

java comes with a solution to that, here the Character Escape Sequence of Java comes to rescue. The escape sequence allows you to embed special characters like double quotes, line feed, carriage return, tab, etc. into the same String. The above example is corrected as follows:-

String str = "Hello, I am Learning \"Java\"";

Now this is the correct way as per Java. What Java sees is that anything after the "\" symbol is to be placed as it is, and is a part of the whole String overall. Though the symbol "\" has different implications with regard to other escape sequences, like "\n" inserts a new line, etc.

The Character escape Sequence in Java is shown below:-

Escape Sequence ------------Purpose
\ddd ------------ Octal character (ddd)
\uxxxx ------------ Hexadecimal UNICODE character (xxxx)
\’ ------------ Single quote
\” ------------ Double quote
\\ ------------ Backslash
\r ------------ Carriage return
\n ------------ New line (also known as line feed)
\f ------------ Form feed
\t ------------ Tab
\b ------------ Backspace

We Are Founder..