Literals

A literal is a constant value of a particular type, written the way it would appear in a program.

Here are some examples of literals of different types:

Type Sample Literals
int 34, -17, 0
double 3.42, 12.0, -14.7
char ‘A’, ‘a’, ‘2’, ‘!’
boolean true, false
String “apple”, “14”, “a”

Notice that character literals must be enclosed in single quotes, and string literals must be enclosed in double quotes.