Every variable in Java has a data type. Java Data Types specify the size and type of values that can be stored. There are a variety of data types available in Java. There are mainly two types of Java Data Types.
Primitive Data Types or Built-in data types.
Non-Primitive Data Types or Reference data types
Primitive Data Types are classified into two category :
Numeric Data Types are two types –
Integer Data Type
Floating-Point Data Type
Non-Numeric Data Types are also two types –
Character Data Type
Boolean Data Type
Integer Data Type : Integer data types can hold whole numbers such as 25, -40, 2456. The size of the values that can be stored depends on your choose’s integer data types. Java supports four types of integer data type and they are byte, short, int and long. Java does not support unsigned integer data types. So, all java values are signed that means those values can be positive or negative.
Floating-Point Data Type : Floating-Point Data Type can also hold whole numbers containing fractional parts such as 25.6675. There are two types of Floating-Point Data Types are given as follows :
Float : The float type values are single precision numbers such as 3.142857. A single precision number using 6 decimal digits.
Double : Double types values are represent double precision number such as 3.142857142857.
A double-precision number using 12 decimal digits.
Character Data Type : Java provides a character data type that is called char. The char type assumes a size of 2 bytes, but it can hold only a single character.
Boolean Data Type : Boolean Data Type is used when we want to test a particular condition during the execution of the program. There are only two values in Boolean Data Types such as true or false.Boolean data type is denoted by the keyword boolean and it uses only one bit of storage.