Class Short

All Implemented Interfaces:
Comparable<Short>

public final class Short extends Number implements Comparable<Short>
The Short class is the standard wrapper for short values. Since: JDK1.1, CLDC 1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
    The maximum value a Short can have.
    static final short
    The minimum value a Short can have.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Short(short value)
    Constructs a Short object initialized to the specified short value.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    compare(short s1, short s2)
     
    int
    compareTo(Short another)
    Compares this object to the specified object to determine their relative order.
    double
     
    boolean
    Compares this object to the specified object.
    float
     
    int
    Returns a hashcode for this Short.
    int
     
    long
     
    static short
    Assuming the specified String represents a short, returns that short's value.
    static short
    parseShort(String s, int radix)
    Assuming the specified String represents a short, returns that short's value in the radix specified by the second argument.
    short
    Returns the value of this Short as a short.
    Returns a String object representing this Short's value.
    static Short
    valueOf(short i)
    Returns the object instance of i

    Methods inherited from class Number

    byteValue

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MAX_VALUE

      public static final short MAX_VALUE
      The maximum value a Short can have. See Also:Constant Field Values
      See Also:
    • MIN_VALUE

      public static final short MIN_VALUE
      The minimum value a Short can have. See Also:Constant Field Values
      See Also:
  • Constructor Details

    • Short

      public Short(short value)
      Constructs a Short object initialized to the specified short value. value - the initial value of the Short
  • Method Details

    • equals

      public boolean equals(Object obj)
      Compares this object to the specified object.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hashcode for this Short.
      Overrides:
      hashCode in class Object
    • parseShort

      public static short parseShort(String s) throws NumberFormatException
      Assuming the specified String represents a short, returns that short's value. Throws an exception if the String cannot be parsed as a short. The radix is assumed to be 10.
      Throws:
      NumberFormatException
    • parseShort

      public static short parseShort(String s, int radix) throws NumberFormatException
      Assuming the specified String represents a short, returns that short's value in the radix specified by the second argument. Throws an exception if the String cannot be parsed as a short.
      Throws:
      NumberFormatException
    • shortValue

      public short shortValue()
      Returns the value of this Short as a short.
      Overrides:
      shortValue in class Number
    • toString

      public String toString()
      Returns a String object representing this Short's value.
      Overrides:
      toString in class Object
    • valueOf

      public static Short valueOf(short i)
      Returns the object instance of i
      Parameters:
      i - the primitive
      Returns:
      object instance
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • compareTo

      public int compareTo(Short another)
      Description copied from interface: Comparable
      Compares this object to the specified object to determine their relative order.
      Specified by:
      compareTo in interface Comparable<Short>
      Parameters:
      another - the object to compare to this instance.
      Returns:
      a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.
    • compare

      public static int compare(short s1, short s2)