Intel

Developer Zone

Short

java.lang

Class Short



  • public class Short
    extends Object
    • Field Summary

      Fields
      Modifier and Type Field and Description
      static short MAX_VALUE
      Constant for the maximum Short value, 215-1
      static short MIN_VALUE
      Constant for the minimum Short value, -215.
    • Constructor Summary

      Constructors
      Constructor and Description
      Short(short value)
      Constructs a new Short with the specified primitive short value.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      boolean equals(Object object)
      Compares this instance with the specified object and indicates if they are equal.
      int hashCode()
      Returns an integer hash code for this short.
      static short parseShort(String string)
      Parses the specified string as a signed decimal short value.
      static short parseShort(String string, int radix)
      Parses the specified string as a signed short value using the specified radix.
      short shortValue()
      Gets the primitive value of this short.
      String toString()
      Converts this short into its decimal string representation.
      static Short valueOf(short s)
      Returns a Short instance for the specified short value.
    • Field Detail

      • MAX_VALUE

        public static final short MAX_VALUE
        Constant for the maximum Short value, 215-1
        See Also:
        Constant Field Values
      • MIN_VALUE

        public static final short MIN_VALUE
        Constant for the minimum Short value, -215.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Short

        public Short(short value)
        Constructs a new Short with the specified primitive short value.
        Parameters:
        value - the primitive short value to store in the new instance.
    • Method Detail

      • shortValue

        public short shortValue()
        Gets the primitive value of this short.
        Returns:
        this object's primitive value.
      • equals

        public boolean equals(Object object)
        Compares this instance with the specified object and indicates if they are equal. In order to be equal, object must be an instance of Short and have the same short value as this object.
        Overrides:
        equals in class Object
        Parameters:
        object - the object to compare this short with.
        Returns:
        true if the specified object is equal to this Short; false otherwise.
        See Also:
        Object.hashCode()
      • toString

        public String toString()
        Converts this short into its decimal string representation. The returned string is a concatenation of a minus sign if the number is negative and characters from '0' to '9'.
        Overrides:
        toString in class Object
        Returns:
        the decimal string representation of value.
      • parseShort

        public static short parseShort(String string)
                                throws NumberFormatException
        Parses the specified string as a signed decimal short value. The ASCII character - ('-') is recognized as the minus sign.
        Parameters:
        string - the string representation of a short value.
        Returns:
        the primitive short value represented by string.
        Throws:
        NumberFormatException - if string is null, has a length of zero or can not be parsed as a short value.
      • parseShort

        public static short parseShort(String string,
                       int radix)
                                throws NumberFormatException
        Parses the specified string as a signed short value using the specified radix. The ASCII character - ('-') is recognized as the minus sign.
        Parameters:
        string - the string representation of a short value.
        radix - the radix to use when parsing.
        Returns:
        the primitive short value represented by string using radix.
        Throws:
        NumberFormatException - if string is null or has a length of zero, radix < Character.MIN_RADIX, radix > Character.MAX_RADIX, or if string can not be parsed as a short value.
      • valueOf

        public static Short valueOf(short s)
        Returns a Short instance for the specified short value.

        If it is not necessary to get a new Short instance, it is recommended to use this method instead of the constructor, since it maintains a cache of instances which may result in better performance.

        Parameters:
        s - the short value to store in the instance.
        Returns:
        a Short instance containing s.
        Since:
        1.5