Java Reference
In-Depth Information
CharacterLiteral
StringLiteral
NullLiteral
3.10.1. Integer Literals
An integer literal may be expressed in decimal (base 10), hexadecimal (base 16), octal
(base 8), or binary (base 2).
IntegerLiteral:
DecimalIntegerLiteral
HexIntegerLiteral
OctalIntegerLiteral
BinaryIntegerLiteral
DecimalIntegerLiteral:
DecimalNumeral IntegerTypeSuffix opt
HexIntegerLiteral:
HexNumeral IntegerTypeSuffix opt
OctalIntegerLiteral:
OctalNumeral IntegerTypeSuffix opt
BinaryIntegerLiteral:
BinaryNumeral IntegerTypeSuffix opt
IntegerTypeSuffix: one of
l L
An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise
it is of type int (ยง 4.2.1 ) .
The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the
digit 1 (one).
Underscores are allowed as separators between digits that denote the integer.
In a hexadecimal or binary literal, the integer is only denoted by the digits after the 0x or 0b
characters and before any type suffix. Therefore, underscores may not appear immediately
after 0x or 0b , or after the last digit in the numeral.
In a decimal or octal literal, the integer is denoted by all the digits in the literal before any
type suffix. Therefore, underscores may not appear before the first digit or after the last di-
git in the numeral. Underscores may appear after the initial 0 in an octal numeral (since 0
Search WWH ::




Custom Search