19 October 2010
0 Typecasting of primitive data types in Java
Typecasting of primitive data types in Java
Variable of smaller capacity can be assigned to another variable of bigger capacity without any explicit typecasting
int i = 10;
double d;
d = i;
double d;
d = i;
Whenever a larger type is converted to a smaller type, the typecast operator has to be explicitly specified. This prevents accidental corruption of data.
double d = 10;
int i;
i = (int) d;
int i;
i = (int) d;
Subscribe to:
Post Comments (Atom)
0 comments:
Please give your valuable comments.