Type Casting
Overview
- Type casting is when you assign a value of one primitive data type to another type.In java, there are two types of casting.
- a) Widening Casting(Automatical) - converting a smaller data type to a larger data type size
byte -> short -> char -> int -> long -> float - > double
- b) Narrowing Casting(Manual) - converting a larger dara type to a smaller data type size
double -> float -> long -> int -> char