Thursday, January 2, 2014

Primitive Data Types Java

Total 8 primitive types are supported by Java.

Data types is nothing but a way to assign different size of memory space to different data. Depending on the size required to store the data, memory space is allocated to it.

To make things easy, In Java we call such memory spaces by name as below,

Data Type
Size
Default Value
Min
Max
boolean
1 bit
false
false
true
char
2 byte
'\u0000'
'\u0000' (or 0)
'\uffff' (or 65,535)
byte
1 byte
0
-128 (-2^7)
127 (2^7 -1)
short
2 byte
0
-32,768 (-2^15)
32,767 (2^15 -1)
int
4 byte
0
- 2,147,483,648 (-2^31)
2,147,483,647 (2^31 -1)
long
8 byte
0L
-9,223,372,036,854,775,808
(-2^63)
9,223,372,036,854,775,807
(2^63 -1)
float
4 byte
0.0f


double
8 byte
0.0d