Fields Summary |
---|
private static final long | serialVersionUID |
private final short | valueThe value which the receiver represents. |
public static final short | MAX_VALUEConstant for the maximum {@code short} value, 215-1. |
public static final short | MIN_VALUEConstant for the minimum {@code short} value, -215. |
public static final int | SIZEConstant for the number of bits needed to represent a {@code short} in
two's complement form. |
public static final Class | TYPEThe {@link Class} object that represents the primitive type {@code
short}. |
Methods Summary |
---|
public byte | byteValue()
return (byte) value;
|
public int | compareTo(java.lang.Short object)Compares this object to the specified short object to determine their
relative order.
return value > object.value ? 1 : (value < object.value ? -1 : 0);
|
public static java.lang.Short | decode(java.lang.String string)Parses the specified string and returns a {@code Short} instance if the
string can be decoded into a short value. The string may be an optional
minus sign "-" followed by a hexadecimal ("0x..." or "#..."), octal
("0..."), or decimal ("...") representation of a short.
int intValue = Integer.decode(string).intValue();
short result = (short) intValue;
if (result == intValue) {
return valueOf(result);
}
throw new NumberFormatException();
|
public double | doubleValue()
return value;
|
public boolean | equals(java.lang.Object object)Compares this instance with the specified object and indicates if they
are equal. In order to be equal, {@code object} must be an instance of
{@code Short} and have the same short value as this object.
return (object instanceof Short)
&& (value == ((Short) object).value);
|
public float | floatValue()
return value;
|
public int | hashCode()
return value;
|
public int | intValue()
return value;
|
public long | longValue()
return value;
|
public static short | parseShort(java.lang.String string)Parses the specified string as a signed decimal short value. The ASCII
character \u002d ('-') is recognized as the minus sign.
return parseShort(string, 10);
|
public static short | parseShort(java.lang.String string, int radix)Parses the specified string as a signed short value using the specified
radix. The ASCII character \u002d ('-') is recognized as the minus sign.
int intValue = Integer.parseInt(string, radix);
short result = (short) intValue;
if (result == intValue) {
return result;
}
throw new NumberFormatException();
|
public static short | reverseBytes(short s)Reverses the bytes of the specified short.
int high = (s >> 8) & 0xFF;
int low = (s & 0xFF) << 8;
return (short) (low | high);
|
public short | shortValue()Gets the primitive value of this short.
return value;
|
public java.lang.String | toString()
return Integer.toString(value);
|
public static java.lang.String | toString(short value)Returns a string containing a concise, human-readable description of the
specified short value with radix 10.
return Integer.toString(value);
|
public static java.lang.Short | valueOf(java.lang.String string)Parses the specified string as a signed decimal short value.
return valueOf(parseShort(string));
|
public static java.lang.Short | valueOf(java.lang.String string, int radix)Parses the specified string as a signed short value using the specified
radix.
return valueOf(parseShort(string, radix));
|
public static java.lang.Short | valueOf(short s)Returns a {@code Short} instance for the specified short value.
If it is not necessary to get a new {@code 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.
if (s < -128 || s > 127) {
return new Short(s);
}
return valueOfCache.CACHE[s+128];
|