In Java, Data types is classified into and categories:
1. Primitive Data Type
2. Non-primitive Data Type
There is 8 primitive data types:
Char boolean byte short int long float double
8 Primitive can classfiied into 4 groups;
Group 1:integer
byte: It is 8 bit integer data type. Value range from-128 to 127. Default value Zero. Examplebyte b=10;
Short : It is a bit integer data type. Value range from-32768 to 32767. Default value Zero. Exampleshort s=11;
int: It is a-bit integer data type. Value range from-2147483648 to 2147483647. Default value Zero. Exampleint i=10;
Long: It is a 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. Examplelong l=100012;
Group 2:floating-point Number
float: It is the + bit float data type. Default value 0.0f. Examplefloat ff=10.3f;
Double: It is a bit float data type. Default value 0.0d. Exampledouble db=11.123;
Group 3:characters
Char: It is a bit unsigned Unicode character. Range 0 to 65,535. Examplechar c=‘a‘;
Group 4:boolean
This group represent boolean
, which are a special type for representing True/false values. They is defined constant of the language. Exampleboolean b=true;
2) non-primitive (Reference) Data Type:
A reference data type is used to refer to an object. A reference variable is declare to being of specific and that type can never are change. We'll talk a lot more about reference data type later in Classes and Object lesson.
Data Types in Java