Type casting is the conversion from 1 data type to another.
It is of 2 types :
In case of widening, we convert smaller datatype like an integer to bigger data type like double.
int a = 4; double b = a; System.out.println(b);
In case of narrowing we convert bigger datatype like double to smaller data type like an integer.
double c = 3.445; int d = (int) c; System.out.println(d);
Here, we learned about Type Casting. In the next article, we’ll learn about operators.