Basic JAVA 2
Data Types in Java
Java language has a rich implementation of data types. Data types specify size and the type of values that can be stored in an identifier
In java, data types are classified into two catagories:
1) Primitive Data type
2) Non-Primitive Data type
1) Primitive Data type :
A primitive data type can be of eight types :
char boolean byte short int long float double
A primitive data type can be of eight types :
Once a primitive data type has been declared its type can never change, although in most cases its value can change. These eight primitive type can be put into four groups:
Data Type | Default Value | Default size |
boolean | false | 1 bit |
char | '\u0000' | 2 byte |
byte | 0 | 1 byte |
short | 0 | 2 byte |
int | 0 | 4 byte |
long | 0L | 8 byte |
float | 0.0f | 4 byte |
double | 0.0d | 8 byte |