2.2 Data Types in Java
2.2 Data Types in Java
Data types specify the different sizes and values that can be stored in the variable. There are
two types of data types in Java:
1. Primitive data types: The primitive data types include boolean, char, byte, short, int,
long, float and double.
2. Non-primitive data types: The non-primitive data types include Classes, Interfaces,
and Arrays.
Example:
Example:
Example:
Example:
1. float f1 = 234.5f
Example:
double d1 = 12.3
6. Char Data Type
The char data type is a single 16-bit Unicode character.The char data type is used to store
characters.
Example: