String literal in java

In this post we are going to learn string literal in java.

String literal is a sequence of unicode characters like numbers, symbols and letters.

String str = "#15, 86d street, Brooklyn";

These characters are enclosed between double quotation mark. Javac compiler converts all string literal characters into unicode code points.

Also read – strings in java

We can use escape sequence like this,

\n – newline character

\t – inserting tab

\b – backspace

\r – carriage return

\’ – insert single quotation mark

\\ – backslash

\” – insert double quotation mark