Thursday, October 14, 2010

Type Casting in Java

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:

AWS certification question

AWS AWS Hi! this is for questions related to AWS questions. EC2 instances EC2 storage types cold HDD : 1. Defines performance in terms...