Package java.lang

Class Number

java.lang.Object
java.lang.Number
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short

public abstract class Number
extends Object
implements Serializable
The abstract superclass of the classes which represent numeric base types (that is Byte, Short, Integer, Long, Float, and Double.
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    Number()
    Empty default constructor.
  • Method Summary

    Modifier and Type Method Description
    byte byteValue()
    Returns this object's value as a byte.
    abstract double doubleValue()
    Returns this object's value as a double.
    abstract float floatValue()
    Returns this object's value as a float.
    abstract int intValue()
    Returns this object's value as an int.
    abstract long longValue()
    Returns this object's value as a long.
    short shortValue()
    Returns this object's value as a short.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Number

      public Number()
      Empty default constructor.
  • Method Details

    • byteValue

      public byte byteValue()
      Returns this object's value as a byte. Might involve rounding and/or truncating the value, so it fits into a byte.
      Returns:
      the primitive byte value of this object.
    • doubleValue

      public abstract double doubleValue()
      Returns this object's value as a double. Might involve rounding.
      Returns:
      the primitive double value of this object.
    • floatValue

      public abstract float floatValue()
      Returns this object's value as a float. Might involve rounding.
      Returns:
      the primitive float value of this object.
    • intValue

      public abstract int intValue()
      Returns this object's value as an int. Might involve rounding and/or truncating the value, so it fits into an int.
      Returns:
      the primitive int value of this object.
    • longValue

      public abstract long longValue()
      Returns this object's value as a long. Might involve rounding and/or truncating the value, so it fits into a long.
      Returns:
      the primitive long value of this object.
    • shortValue

      public short shortValue()
      Returns this object's value as a short. Might involve rounding and/or truncating the value, so it fits into a short.
      Returns:
      the primitive short value of this object.