The eight primitive data types handle common types for
integers, floating-point numbers, characters, and boolean values (true or false).
They're called primitive because they're built into
the system and are not actual objects, which makes them more efficient to use.
Integer Type
There are four Java integer types, each with a different range of values.
All are signed, which means they can hold either positive or negative numbers.
Table 3.1. Integer types
Type
Size
Range
byte
8 bits
-128 to 127
short
16 bits
-32,768 to 32,767
int
32 bits
-2,147,483,648 to 2,147,483,647
long
64 bits
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Floating-point type:
Floating-point numbers are used for numbers with a decimal part.
There are two floating-point types: float (32 bits, single precision) and double (64 bits,
double precision).
Char type:
The char type is used for individual characters.
Because Java uses the Unicode character set, the char type has 16
bits of precision, unsigned.