0

why is typecasting done in java?

30th Mar 2017, 1:06 AM
Rabin Karki
Rabin Karki - avatar
2 Answers
+ 1
Assigning a value of one type to a variable of another type is known as Type Casting. If I ask for the user a input for a item quantity and I get it as an integer: int qtt = 2; Imagine I want get this quantity as a float 2.00, so I need to Type Cast this int into float: float newQtt = (float)qtt;
30th Mar 2017, 1:21 PM
Felipe Cruz
Felipe Cruz - avatar
0
thank you Felipe
30th Mar 2017, 1:58 PM
Rabin Karki
Rabin Karki - avatar