Data type describes the various sizes as well as values that can be stored in a variable.
Data Types can be categorized into two types:
Primitive data consists of only single values and has no special capabilities.
There are 8 primitive data types:
Non-primitive data types, unlike primitives, are user-defined rather than predefined, referring to locations in memory where objects exist when defined, allowing for greater programming flexibility and customization.
There are mainly 5 non-primitive data types :
A type casting is a method for converting one data type into another. We can cast both primitive and reference data types. Only the data type can be modified; the data itself cannot.
Java has two types of type casting:
A lower data type is converted to a higher one using a technique known as widening type casting. Some call it implicit type casting or casting down. It happens naturally.
Narrow type casting is the process of reducing a larger data type to a smaller one. It's also known as casting up or explicit type casting. It does not occur on its own. Narrowing type casting is risky because data loss may occur due to the lower data type's reduced range of allowable values.