The Primitive Types

Java defines eight primitive types of data: byte, short, int, long, char, float, double, and boolean.

Primitive TypeReserved WordSizeMin ValueMax Value
Characterchar16-bitUnicode 0Unicode 216 - 1
Byte integerbyte8-bit-128+127
Short integershort16-bit-21+215 - 1
Integerint32-bit-231+231 - 1
Long integerlong64-bit-263+263 - 1
Double precision floating-pointdouble64-bit4.9e-3241.8e+308

byte, short, int, and long are for whole-valued signed numbers. float and double are fractional precision numbers.

char represents symbols in a character set, like letters and numbers. boolean represents true/false values.


Java defines four integer types: byte, short, int, and long.

Integer types are signed, positive and negative values.

The width and ranges of these integer types vary widely:

long64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
int32-2,147,483,648 to 2,147,483,647
short16-32,768 to 32,767
byte8-128 to 127

Floating Point Types

There are two kinds of floating-point types: float and double. float type represents single-precision numbers. double type stores double-precision numbers.

Floating-Point Types width and ranges are shown here:

NameWidth in BitsApproximate Range
double644.9e-324 to 1.8e+308
float321.4e-045 to 3.4e+038
  Java Book 
    Language Basics  

Primitive Types:
  1. The Primitive Types
  2. byte
  3. short
  4. int
  5. long
  6. float
  7. double
  8. char
  9. boolean