Primitive Type Wrappers

  • Java uses primitve types such as int, char, float whose performance is greater when compare to Objects.
  • These data types are not part of the object hierarchy.

  • These are passed by value to the methods not by reference.

  • There is no way for two methods to refer to the same instance of an int.

Number

  • The abstract class Number defines a superclass that is implemented by the classes that wrap the numeric types byte,short, int, long, float,and double.

  • It have abstract methods that return the value of the object in each of the different number formats.

byte byteValue( )//returns byte value

double doubleValue( ) //returns double value

float floatValue( )//returns float value

int intValue( ) //returns integer value

long longValue( ) //returns long type value

short shortValue( ) //returns short type value

  • The values returned by these methods might be rounded,truncated,or result in a “garbage”value due to the effects of a narrowing conversion.

  • Number has concrete subclasses that hold explicit values of each primitive numeric type:Double, Float, Byte, Short, Integer, and Long.

results matching ""

    No results matching ""