Literals

Integers
0b11110101 (0b followed by a binary number)
0365 (0 followed by an octal number)
0xF5 (0x followed by a hexadecimal number)
245 (decimal number)

Floating-point values
23.5F, .5f, 1.72E3F (decimal fraction with an optional exponent indicator,
followed by F)
0x.5FP0F, 0x.5P-6f (0x followed by a hexadecimal fraction with a mandatory
exponent indicator and a suffix F)
23.5D, .5, 1.72E3D (decimal fraction with an optional exponent indicator,
followed by optional D)
0x.5FP0, 0x.5P-6D (0x followed by a hexadecimal fraction with a mandatory
exponent indicator and an optional suffix D)

Character literals
'a', 'Z', '\u0231' (character or a character escape, enclosed in single quotes)

Boolean literals
true, false

null literal
null

String literals
"Hello, World" (sequence of characters and character escapes enclosed in
double quotes)

Characters escapes in strings
\u3876 (\u followed by the hexadecimal unicode code point up to U+FFFF)
\352 (octal number not exceeding 377, preceded by backslash)
\n
\r
\f
\\
\'
\"
\t
\b

Integer literals are of int type by default unless long type is specified by appending L or l suffix to the
literal, e.g. 367L. Since Java SE 7 it is possible to include underscores between numbers to increase
readbility, for example a number 145608987 may be written as 145_608_987.
Variables

No comments:

Post a Comment