Type casting is a way of converting data from one data type to another data type. This process of data conversion is also known as type conversion or type coercion.
In Java, we can cast both reference and primitive data types. By using casting, data can not be changed but only the data type is changed.
Note: type casting is not possible for a Boolean
data type.
There are 13 types of conversion in Java. In this article, we will only look at 2 major types:
- Implicit casting.
- Explicit casting.
example of casting to float in java