Based on the type of data stored, data types are classifying as 3 types in Java.
- Primitive Datatype (Fundamental Datatype):
- Derived Datatype
- User Defined Datatype
Primitive Datatype (Fundamental Datatype):
The datatype which stores only single value is Primitive datatype. Primitive datatypes are also known as fundamental datatypes. In java programming language, there are 8 primitive datatypes classified into 4 categories.
- Integer type category
- Floating-point category
- Character type category
- Boolean type category
Derived Datatypes:
Derived datatypes are pre-defined datatypes given by the programming language. These derived datatypes are created by primitive datatypes and they can be used for storing multiple values.
Ex: Array
User Defined Datatypes:
These datatypes will be created by the programmer according to application requirement, in which we can store any type of values and number of values.
Ex: Class
1. Integer Category Data Types:
This category can be used for storing numbers which can be either +ve or -ve without decimal points.
We have 4 types under integer category. The size and range are as below:
Data Type Size Range
byte 1 Byte (2^8) -128 to 127
short 2 Bytes -32768 to 32767
int 4 Bytes -2,147,483,648 to 2,147,483,647
long 8 Bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
2. Floating-Point Category Data Types:
This category can be used for storing numbers which can be +ve or -ve with decimal points. We have two types under floating point category:
Data Type Size Range
float 4 Bytes 1.4 e^-45 to 3.4 e^38
double 8 Bytes 4.9e^-324 to 1.8 e^308
3. Character Type Category Data Type:
This category can be used for storing a single character. A character can be represented by an Alphabet or a digit or a special symbol.
This category contains only one datatype that is Char.
Data Type Size Range
Char 2 Bytes 0 to 65535
4. Boolean Type Category Data Type:
This category can be used for storing either True or False. We have only one datatype under this category that is Boolean.
Data Type Size Range
Boolean JVM Dependent True or False
1. Integer Category Data Types:
This category can be used for storing numbers which can be either +ve or -ve without decimal points.
We have 4 types under integer category. The size and range are as below:
Data Type Size Range
byte 1 Byte (2^8) -128 to 127
short 2 Bytes -32768 to 32767
int 4 Bytes -2,147,483,648 to 2,147,483,647
long 8 Bytes -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
2. Floating-Point Category Data Types:
This category can be used for storing numbers which can be +ve or -ve with decimal points. We have two types under floating point category:
Data Type Size Range
float 4 Bytes 1.4 e^-45 to 3.4 e^38
double 8 Bytes 4.9e^-324 to 1.8 e^308
3. Character Type Category Data Type:
This category can be used for storing a single character. A character can be represented by an Alphabet or a digit or a special symbol.
This category contains only one datatype that is Char.
Data Type Size Range
Char 2 Bytes 0 to 65535
4. Boolean Type Category Data Type:
This category can be used for storing either True or False. We have only one datatype under this category that is Boolean.
Data Type Size Range
Boolean JVM Dependent True or False
0 comments:
Post a Comment