The Primitive data types are designed to store a single value and they are used to store the basic inputs required for a program. The primitive types are also called as fundamental data types.
The Java language provides 8 primitive data types and those are classified into 4 categories
This category can used for storing numbers, either positive or negative without a decimal point. Under integer category we have 4 primitive data types and those are
All the 4 primitive data types are used for storing same kind of data, but their sizes and ranges are different so that the memory can be utilized efficiently without any wastage.
|Byte||1||-128 to 128|
|Short||2||-32768 to 32767|
|Int||4||-2147483648 to 2147483647|
|Long||8||-9223372036854775808 to 9223372036854775807|
This category used for storing numbers either positive or negative with decimal point. Under the floating point category we have two primitive datatypes those are
Both primitive data types under floating -point category are used for storing same kind of data, but their sizes are different so that memory can be utilized efficiency without waste.
|Range||Number of decimal digits|
|Float||4||1.4E-45 to 3.4E38||7|
|Double||8||4.9E-324 to 1.79E308||15|
This category used for storing a single character. A character can be represented by either one alphabet or one digit or one special symbol. Under the character category there is only one primitive data type and it is Char
|Char||2||0 to 65535|
This category used for storing either true or false. Under the Boolean category we have one primitive data type i.e. Boolean.
|Boolean||JVM Dependent||True or false|