DEV Community

Surya
Surya

Posted on

Type casting in java

Today I came by 9.00 clock Today I learned what is type casting in java. Type casting means converting a variable of one data type into another
Example:Converting an int into a double,or an object of one class into another.
Types of casting in java
1.widening
converts a smaller data type into a larger data type.
*Done automatically by the compiler.
2.
Narrowing*
*converts a larger data type into a smaller one.
*Risk of data loss or precision loss.

Top comments (0)