Chapter 5
⦁ If we want to store a value of lower size data type value into higher size data type variable
e.g. float a=3;
it is permissible in java language. this type of the conversion is called widening conversion.
⦁ We cannot directly assign a higher size data type variable e.g.
syntax to assign higher size data type value into lower size data type variable
HigherSizeDatatype variable=(lowersizedat type) value ;
e.g. int a=(int)3.5;
⦁ It will assign integer part of 3.5 which is 3 to a.
Type conversion in Java
The process through which we convert value of one data type into another data type is called as Type Conversion.⦁ If we want to store a value of lower size data type value into higher size data type variable
e.g. float a=3;
it is permissible in java language. this type of the conversion is called widening conversion.
⦁ We cannot directly assign a higher size data type variable e.g.
int a=3.5; //error
syntax to assign higher size data type value into lower size data type variable
HigherSizeDatatype variable=(lowersizedat type) value ;
e.g. int a=(int)3.5;
⦁ It will assign integer part of 3.5 which is 3 to a.
Comments
Post a Comment