Main Data Types of Java
Variables are nothing more than memory addresses dedicated for storing values. This means that when you declare a variable, you allocate memory for it.
​
The operating system allocates memory and determines what can be put in reserved memory based on the data type of a variable. As a result, by associating variables with multiple data types, you can store integers, decimals, or characters in these variables.
​
There are two data types in Java:
Primitive Data Types
Primitive data types are the ones which are predefined by the programming language which in this case is Java. Without primitive data types it would be impossible to frame programs. Primitive data types are also the building blocks of Non-primitive data types.
​
Types of Java Primitive Data Types:
​
-
​Int
-
Float
-
Char
-
Boolean
-
Byte
-
Short
-
Long
-
Double
Non- Primitive Data Types
These are the datatypes which have instances like objects. Hence they are called reference variables.
​
Types of Java Non-Primitive Data Types:
​
-
​Classes
-
Interfaces
-
Strings
-
Arrays