What are primitive data types in Java?

Primitive data types are built in data types. Primitive data types are also called as Basic data types.

1.Integer Types

Different Types differ in memory size and range of values.

Integer Type Size Range
byte 1 byte -128 to 127
short 2 bytes -215 to (215)-1
int 4 bytes -231 to (231)-1
long 8 bytes -263 to (263)-1

In java, only signed integers exist. Java does not have signed and unsigned keywords.
Unsigned values are not supported in Java

byte binary representation
byte binary representation

2.Decimal Types

There are two decimal types supported in Java. Below table, shows details on the same.

Decimal Type Size Range
float 4 bytes -3.7e-38 to 3.7e+38(Scientific notation)
double 8 bytes -1.4e-308 to 1.4e+308

NOTE:-3.7e-38 means -3.7 X 10 power of -38
Scientific notation is used to express very small or big values

How to declare and initialize float and double?
float abcd=1.2f;
double wxy=4.67;

3.Character Type

In C language 1 byte is used to store each character
ASCII(can represent only 255 different characters), and supports only English related characters
In Java 2 bytes are used to store each character. UNICODE is the code used to store characters in Java.
UNICODE Can represent 65,535 different characters.
Though UNICODE uses extra 1 byte, for each character, it supports most of the international characters directly, unlike ASCII code.
Java has built in support for internationalization(i18n)


boolean data type is used to represent only two values true or false. boolean uses 1 bit of storage

Above are eight primitive data types in Java.

You may also like to read:
String object with and without new?
Difference between equals() and ==?