, We can convert instances of compatible types, which creates a new value from the old one.
Implicit conversions will happen automatically and hence they are also called as normal conversions.
int x = 5;
long y = x;
In the above example, we are converting a 32 bit integer
) to a 64 bit integer
) implicitly (normally).
There are some conditions that must be satisfied to allow the implicit conversions. They are,
conversions can be allowed only if the compiler guarantee's the success of conversion.
conversions can be allowed only if there will be no loss of information in the conversion process.
Asked In: Spotted While Learning |