Java Data Types

PRIMITIVE DATA TYPES

          Primitive types

        “building blocks” for more complicated types

          Java is strongly typed

        All variables in a Java program must have a type

          Java primitive types

        portable across computer platforms that support Java

TYPE

Size in Bytes

VALUES

boolean

1

true or false

Byte

1

–128 to +127  (–27 to 27 – 1)

Char

2

u0000’ to ’uFFFF’  (0 to 65535)

short

2

–32,768 to +32,767  (–215 to 215 – 1)

Int

4

–2,147,483,648 to +2,147,483,647  (–231 to 231 – 1)

Float

4

 -ive range:–3.4028234663852886E+38 to –1.40129846432481707e–45

+ive range:1.40129846432481707e–45 to 3.4028234663852886E+38

Long

8

–9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 (–263 to 263 – 1)

Double

8

-ive  range: –1.7976931348623157E+308 to –4.94065645841246544e–324

+ive range:  4.94065645841246544e–324 to 1.7976931348623157E+308