You are on page 1of 1

Literals in Java

A literal is an explicit (stated clearly) number or string constant used in Java


programs.

Examples:

int:

 1, 0, -1, 025 (Octal), 0B10101 (Binary), 0x0DA9 (Hexa-decimal), '\u0041' (Unicode)


 Integer.MAX_VALUE => 2147483647, Integer.MIN_VALUE => -2147483648
 123_456_3456

byte / Short:

(byte) 0xff, (short)-25

long:

5L, -200L, 0xFD9CL

Long.MAX_VALUE => 263-1, Long.MIN_VALUE => -263 (9,223,372,036,854,775,807)

float:

1.234F, 1.05E-12f,

Float.NaN

double:

5.5E-120D, 0.001

Double.NaN, Math.PI

Boolean:

true, false

char

'A', '\u003a'

Space

' '

String:

"ITUM"

You might also like