Showing posts with label Literals. Show all posts
Showing posts with label Literals. Show all posts

Wednesday, 23 November 2011

Literals in Java

Integer literals can be decimal, octal, or hexadecimal.

Octal literals begin with zero and only digits 0 through 7 are allowed. For instance:

011


Hexadecimal literals begin with 0x or oX, the digits allowed are 0 through 9 and a through f (or A through F). For instance:

0x0001;


All integer literals are of type int by default. To define them as long, we can place a suffix of L or l after the number.

For char literals, a single character is enclosed in single quotes. You can also use the prefix \u followed by four hexadecimal digits