Boolean Literals, Character Literals, String Literals in Java

Boolean Literals: Boolean literal has only a single value, either true or false.

Character Literals: In Java, characters are 16 bit Unicode. A character literal is denoted by literal in pair of single quotes. Also, it has a collection of escape sequences:

1) \b: For backspace

2) \t: For tab

3) \n: For new line or line feed

4) \f: For form feed

5) \’: For single quote

6) \”: For double quote

7) \\: For backslash

8) \r: For carriage return

9) \ddd: For octal character

10) \uxxxx: For hexadecimal Unicode character

String Literals: Strings are denoted by characters in a pair of double quotes. Example: “More Process”. A Java string has to begin and end in one line and there is no way for line continuity.

Leave a Reply