Class Short
java.lang.Object
java.lang.Number
java.lang.Short
- All Implemented Interfaces:
Comparable<Short>
The Short class is the standard wrapper for short values.
Since: JDK1.1, CLDC 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe size of a short in bytes.static final shortThe maximum value a Short can have.static final shortThe minimum value a Short can have.static final intThe size of a short in bits. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompare(short s1, short s2) intCompares this object to the specified object to determine their relative order.static intcompareUnsigned(short x, short y) Compares the two as unsigned values.static ShortDecodes a decimal, hexadecimal or octal short, asInteger.decode.doublebooleanCompares this object to the specified object.floatinthashCode()Returns a hashcode for this Short.static inthashCode(short value) The value itself.intintValue()longstatic shortparseShort(String s) Assuming the specified String represents a short, returns that short's value.static shortparseShort(String s, int radix) Assuming the specified String represents a short, returns that short's value in the radix specified by the second argument.static shortreverseBytes(short i) The bytes in reverse order.shortReturns the value of this Short as a short.toString()Returns a String object representing this Short's value.static StringtoString(short s) The decimal string ofs.static inttoUnsignedInt(short x) The value as an unsigned int.static longtoUnsignedLong(short x) The value as an unsigned long.static ShortvalueOf(short i) Returns the object instance of istatic ShortA Short ofparseShort(s).static ShortA Short ofparseShort(s, radix).
-
Field Details
-
MAX_VALUE
public static final short MAX_VALUEThe maximum value a Short can have. See Also:Constant Field Values- See Also:
-
MIN_VALUE
public static final short MIN_VALUEThe minimum value a Short can have. See Also:Constant Field Values- See Also:
-
TYPE
-
BYTES
public static final int BYTESThe size of a short in bytes.- See Also:
-
SIZE
public static final int SIZEThe size of a short in bits.- 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 -
Short
-
-
Method Details
-
equals
-
hashCode
-
parseShort
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
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:
shortValuein classNumber
-
toString
-
valueOf
Returns the object instance of i
Parameters
i: the primitive
Returns
object instance
-
intValue
-
longValue
-
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
compareTo
Description copied from interface:ComparableCompares this object to the specified object to determine their relative order.
Parameters
another: the object to compare to this instance.
Returns
- Specified by:
compareToin interfaceComparable<Short>- Returns:
a negative integer if this instance is less than
another; a positive integer if this instance is greater thananother; 0 if this instance has the same order asanother.Throws
ClassCastException: @throws ClassCastException ifanothercannot be converted into something comparable tothisinstance.
-
compare
public static int compare(short s1, short s2) -
toString
The decimal string ofs. -
valueOf
A Short ofparseShort(s).- Throws:
NumberFormatException
-
valueOf
A Short ofparseShort(s, radix).- Throws:
NumberFormatException
-
decode
Decodes a decimal, hexadecimal or octal short, asInteger.decode.- Throws:
NumberFormatException
-
hashCode
public static int hashCode(short value) The value itself. -
compareUnsigned
public static int compareUnsigned(short x, short y) Compares the two as unsigned values. -
toUnsignedInt
public static int toUnsignedInt(short x) The value as an unsigned int. -
toUnsignedLong
public static long toUnsignedLong(short x) The value as an unsigned long. -
reverseBytes
public static short reverseBytes(short i) The bytes in reverse order.
-