What are different data types in Java?
n java, to create a function or perform any action we need variables and since Java is statically typed programming language, so it becomes important to define variables before its being used.
The syntax for defining variable in java is: Data-type Variable-name;
There are two different data types in Java
- Primitive data Types: These are predefined data types in Java. There are eight different primitive data types. These are – Boolean, char, byte, short, int, long, float, double. These are reserved keywords.
- Non-Primitive data types: This is also known as user defined data types or reference data types. These are created by the programmers. They refer to an object.