Casting is basically we convert the primitive values from one type to another, caste can be implicit or explicit.
Implicit caste: its basically means we don\'t have to write code for the cast; the conversion happens automatically. Typically, an implicit cast happens when we\'re doing a widening conversion. We mwan to say putting a smaller thing like bytes into a bigger container like an int. Remember those possible loss of precision compiler errors we saw in the assignments section, Those happened when we tried to put a larger thing like a long into a smaller container like a short.
Explicit cast: In this case The large value into small container conversion is referred to as narrowing and requires an explicit cast, where we tell the compiler that we\'re aware of the danger and accept full responsibility.
code for the implicit :
int a = 100;
long b = a; // Implicit cast, an int value always fits in a long code for the explicit :
float a = 100.001;
int b = (int)a; // Explicit cast, a float can lose info as an int