Type Casting in Java ( Java Part -3 )
Type Casting in Java
Type casting is the practice of converting a data type from one type to another. In Java there are two type of type conversions. The type casting is fully similar to that of type conversion in C and C++.
1. Widening Casting : - This is used to convert from smaller range data type to larger range datatype. Generally these are done automatically.
byte
-> short
-> char
-> int
-> long
-> float
-> double
2 Narrowing Casting :- This is used to convert from larger data type to smaller data type. Generally this type of type conversion is done manually.
double
-> float
-> long
-> int
-> char
-> short
-> byte
Comments
Post a Comment