Whenever we create variables, we always mention the type of data we’ll be putting into the variable using data type.
int a = 4;
There are 2 types of data types in Java.
1. Primitive data type
2. Non Primitive data type
Primitive data types
Primitive data types are also known as fundamental data types. Here we are going to cover some of the most important data types.
Boolean Data Type
Boolean can only store ither true or false values.
|boolean a = true;|
Integer Data Type
Integers stores whole numbers. Whole numbers are non decimal numbers like -2, -1 , 0 ,1 ,2 , etc.
|int a = 3;|
Double Data Type
Double stores decimal numbers like 3.2 , 1,2 ,etc.
|double a = 3.4;|
Char Data Type
Char is ued to store a single character/letter
|char a = 'a';|
Non Primitive data types
Now, we’ll be covering non primitive data types. Major examples for data types include Arrays, ArrayLists, Interfaces, etc.
|String a = "Aniket";|