Inheritance Hierarchy for Wrappers

(in java.lang package)

class Number  defines

doubleValue()
floatValue()
intValue()
longValue()

These can be used on all children  of Number as well.

 

Primitive types (non-objects) may also be cast:

int x;
  :
  :
float y;
y = 5.0/(float)x;
x = (int)y;

This is more expensive:

x = (new Float(y)).intValue();

 

To Next Slide To Previous Slide To Contents