is new.
java.lang.Objectjava.lang.Number
java.lang.Short
<
Short
>
The Short class wraps a value of primitive type short in an object. An object of type Short contains a single field whose type is short.
In addition, this class provides several methods for converting a short to a String and a String to a short, as well as other constants and methods useful when dealing with a short.
| Field Summary | |
|---|---|
| static short |
MAX_VALUE
A constant holding the maximum value a short can have, 2 15 -1. |
| static short |
MIN_VALUE
A constant holding the minimum value a short can have, -2 15 . |
static int
|
SIZE
The number of bits used to represent a
short
value in two's complement binary form.
|
|
|
static
Class
<
Short
|
TYPE
The Class instance representing the primitive type short.
|
| Constructor Summary | |
|---|---|
|
Short
(short value) Constructs a newly allocated Short object that represents the specified short value. |
|
|
Short
(
String
s) Constructs a newly allocated Short object that represents the short value indicated by the String parameter. |
|
| Method Summary | |
|---|---|
| byte |
byteValue
() Returns the value of this Short as a byte. |
|
|
| int |
compareTo
(
Short
anotherShort) Compares two Short objects numerically. |
| static Short |
decode
(
String
nm) Decodes a String into a Short. |
| double |
doubleValue
() Returns the value of this Short as a double. |
| boolean |
equals
(
Object
obj) Compares this object to the specified object. |
| float |
floatValue
() Returns the value of this Short as a float. |
| int |
hashCode
() Returns a hash code for this Short. |
| int |
intValue
() Returns the value of this Short as an int. |
| long |
longValue
() Returns the value of this Short as a long. |
| static short |
parseShort
(
String
s) Parses the string argument as a signed decimal short. |
| static short |
parseShort
(
String
s, int radix) Parses the string argument as a signed short in the radix specified by the second argument. |
static short
|
reverseBytes
(short i)
Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified
short
value.
|
| short |
shortValue
() Returns the value of this Short as a short. |
| String |
toString
() Returns a String object representing this Short's value. |
| static String |
toString
(short s) Returns a new String object representing the specified short. |
static
Short
|
valueOf
(short s)
Returns a
Short
instance representing the specified
short
value.
|
| static Short |
valueOf
(
String
s) Returns a Short object holding the value given by the specified String. |
| static Short |
valueOf
(
String
s, int radix) Returns a Short object holding the value extracted from the specified String when parsed with the radix given by the second argument. |
| Methods inherited from class java.lang. Object |
|---|
| clone , finalize , getClass , notify , notifyAll , wait , wait , wait |
Methods inherited from interface java.lang.
Comparable
|
|---|
compareTo
|
| Field Detail |
|---|
public static final short MIN_VALUE
public static final short MAX_VALUE
public static final Class<
Short
> TYPE
SIZE
public static final int
SIZE
The number of bits used to represent a
short
value in two's complement binary form.
See Also:
Constant Field Values
| Constructor Detail |
|---|
public Short(short value)
public Short(String s)
throws NumberFormatException
| Method Detail |
|---|
public static String toString(short s)
public static short parseShort(String s)
throws NumberFormatException
public static short parseShort(String s,
int radix)
throws NumberFormatException
An exception of type NumberFormatException is thrown if any of the following situations occurs:
public static Short valueOf(String s,
int radix)
throws NumberFormatException
In other words, this method returns a Short object equal to the value of:
new Short(Short.parseShort(s, radix))
public static Short valueOf(String s)
throws NumberFormatException
In other words, this method returns a Byte object equal to the value of:
new Short(Short.parseShort(s))
valueOf
public static
Short
valueOf
(short s)
Returns a
Short
instance representing the specified
short
value. If a new
Short
instance is not required, this method should generally be used in preference to the constructor
Short(short)
, as this method is likely to to yield significantly better space and time performance by cacheing frequently requested values.
Parameters:
s - a short value.
Returns:
a
Short
instance representing
s
.
Since:
1.5
public static Short decode(String nm)
throws NumberFormatException
DecimalNumeral , HexDigits , and OctalDigits are defined in §3.10.1 of the Java Language Specification .
- DecodableString:
- Sign opt DecimalNumeral
- Sign opt 0x HexDigits
- Sign opt 0X HexDigits
- Sign opt # HexDigits
- Sign opt 0 OctalDigits
- Sign:
- -
The sequence of characters following an (optional) negative sign and/or radix specifier ("0x", "0X", "#", or leading zero) is parsed as by the Short.parseShort method with the indicated radix (10, 16, or 8). This sequence of characters must represent a positive value or a NumberFormatException will be thrown. The result is negated if first character of the specified String is the minus sign. No whitespace characters are permitted in the String.
public byte byteValue()
public short shortValue()
public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()
public String toString()
public int hashCode()
public boolean equals(Object obj)
public int compareTo(Short anotherShort)
reverseBytes
public static short
public intreverseBytes
compareTo(short i)
(Objecto)
Returns the value obtained by reversing the order of the bytes in the two's complement representation of the specified
short
value.
the value obtained by reversing (or, equivalently, swapping) the bytes in the specified
short
value.
1.5