Number

Name

Number

Synopsis

Description

The Number class is an abstract class that serves as the superclass for all of the classes that provide object wrappers for primitive numeric values: byte, short, int, long, float, and double. Wrapping a primitive value is useful when you need to treat such a value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a primitive value for one of these arguments, but you can provide a reference to an object that encapsulates the primitive value. Furthermore, as of JDK 1.1, these wrapper classes are necessary to support the Reflection API and class literals.

The Number class defines six methods that must be implemented by its subclasses: byteValue(), shortValue(), intValue(), longValue(), floatValue(), and doubleValue(). This means that a Number object can be fetched as an byte, short, int, long, float, or double value, without regard for its actual class.

Class Summary

public abstract class java.lang.Number extends java.lang.Number implements java.io.Serializable {
 // Instance Methods public abstract byte byteValue(); // New in 1.1 public abstract double doubleValue();
public abstract float floatValue();
public abstract int intValue();
public abstract long longValue();
public abstract short shortValue(); // New in 1.1
}

Instance Methods

byteValue

public abstract byte byteValue()

doubleValue

public abstract double doubleValue()

floatValue

public abstract float floatValue()

intValue

public abstract int intValue()

longValue

public abstract long longValue()

shortValue

public abstract short shortValue()

Inherited Methods

Method Inherited From Method Inherited From
clone() Object equals(Object) Object
finalize() Object getClass() Object
hashCode() Object notify() Object
notifyAll() Object toString() Object
wait() Object wait(long) Object
wait(long, int) Object

See Also

Byte; Double; Float; Integer; Long; Object; Short