Type Casting in Java
Point 1 : In Java Type Casting Done automatically in the below order.
byte(8) -> short(16) -> int(32) -> long(64) ->float(32) -> double(64)
Point 2 : Forcing the above typecasting in reverse order is called Explicit Type-
Casting.
double - > float - > long -> int -> short -> byte.
Disadvantage of Explicit Type Casting :
1) Loss of data
Example : float value = 99.9999 will store in int as 99.
Implicit Type Casting :
Is what the 'JVM' Performs automatically.
Generally those are Up Casting or called as Promotion.
No comments:
Post a Comment