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 categories :
- Primitive Datatype.
- Non-Primitive Datatype.
1) Primitive Datatype
A primitive data type can be of eight types
| Primitive Data types | |||||||
|---|---|---|---|---|---|---|---|
char | boolean | byte | short | int | long | float | double |
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
Integer
This group includes
byte, short, int, long
byte : It is 8 bit integer data type. Value range from -128 to 127. Default value zero. example:
byte b=10;
short : It is 16 bit integer data type. Value range from -32768 to 32767. Default value zero. example:
short s=11;
int : It is 32 bit integer data type. Value range from -2147483648 to 2147483647. Default value zero. example:
int i=10;
llong:It is 64 bit integer data type. Value range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value zero. example:
long l=100012;Floating-Point Number
This group includes
float, double
float : It is 32 bit float data type. Default value 0.0f. example:
float ff=10.3f;
double : It is 64 bit float data type. Default value 0.0d. example:
double db=11.123;

Comments
Post a Comment