Data types

It is a format that any variable is able to store.
In java there are two types of data types.

Primitive and Non primitive.

Primitive data types:-

The fundamental datatypes that are integral part of the java are called primitive data types.
These are given to the user by the java compiler. All the primitive data types have a fixed size. Whenever programmer creates a variable using the primitive data types that particular no. Of bytes are reserved in memory.

They are ready to use data types.
The user can make an instance of the data type and use it to store a particular type of data.

There are 8 primitive data types and theirs sizes(the no of bytes they reserve in the memory)
int size 4 bytes
float 4 byes
long 8 bytes
double 8 bytes
char 2 bytes byte 1 byte boolean 1 bit short. 2 bytes

Non primitive data types:-
These are called user defined data types also, because they are created with the help of primitive data types by the user.
The size is not fixed.
Array, class and interface are examples of non primitive data types.

LEAVE A REPLY

Please enter your comment!
Please enter your name here