You are on page 1of 1

Primitive Data Types

1. Integer
Integer types can hold whole numbers such as 123 and 96. The size of the values t
hat can be stored depends on the integer type that we choose.
Type
byte
short
int
long

Size
1 byte
2 bytes

Range of values that can be stored


128 to 127
32768 to 32767
4 bytes
2,147,483,648 to 2,147,483,647
8 bytes
9,223,372,036,854,775,808 to 9,223,372,036,854,755,807

2. Floating Point
Type
float
double

Size
4 bytes
8 bytes

Range of values that can be stored


3.4e038 to 3.4e+038
1.7e308 to 1.7e+038

3. Character
It stores character constants in the memory. It assumes a size of 2 bytes, but b
asically it can hold only a single character because char stores unicode charact
er sets. It has a minimum value of u0000 (or 0) and a maximum value of uffff (or 65,
535, inclusive).
The Eight Data Types of Java
Type
byte
float
double
char

Explanation
An 8 bit (1 byte) integer value
A 32 bit (4 byte) floating point value
A 64 bit (8 byte) floating point value
A 16 bit character using the Unicode encoding scheme

You might also like