Integer Literals

Integer literals are used to represent specific integer values. Because integers can be expressed as decimal (base 10), octal (base 8), or hexadecimal (base 16) numbers in Java, each representation has its own form of literal. In addition, integer literals can also be expressed with an uppercase L ('L') or lowercase L ('l') at the end to instruct the compiler to treat the number as a long (64-bit) integer.

As with C and C++, Java identifies any number that begins with a non-zero digit and does not contain a decimal point as a decimal integer literal (for example, any number between 1 and 9). To specify an octal literal, you must precede the number with a leading 0 (for example, 045 is the octal representation of 37 decimal). ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.