加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090228220626/http://developer.android.com:80/reference/java/lang/Short.html
public final class

Short

extends Number
implements Comparable<T>
java.lang.Object
   ↳ java.lang.Number
     ↳ java.lang.Short

Class Overview

Short is the wrapper for the primitive type short.

See Also

Summary

Constants
short MAX_VALUE

Constant for the maximum short value, 215-1.

short MIN_VALUE

Constant for the minimum short value, -215.

int SIZE

Constant for the number of bits to represent a short in two's compliment form.

Class<Short> TYPE The java.lang.Class that represents this class.
Public Constructors
Short(String string)
Constructs a new instance of this class given a string.
Short(short value)
Constructs a new instance of the receiver which represents the short valued argument.
Public Methods
byte byteValue()
Returns the byte value which the receiver represents
int compareTo(Short object)

Compares this Short to the Short passed.

static Short decode(String string)
Parses the string argument as if it was a short value and returns the result.
double doubleValue()
Returns the double value which the receiver represents
boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
float floatValue()
Returns the float value which the receiver represents
int hashCode()
Returns an integer hash code for the receiver.
int intValue()
Returns the int value which the receiver represents
long longValue()
Returns the long value which the receiver represents
static short parseShort(String string)
Parses the string argument as if it was a short value and returns the result.
static short parseShort(String string, int radix)
Parses the string argument as if it was a short value and returns the result.
static short reverseBytes(short s)

Reverses the bytes of a short.

short shortValue()
Returns the short value which the receiver represents
static String toString(short value)
Returns a string containing a concise, human-readable description of the argument.
String toString()
Returns a string containing a concise, human-readable description of the receiver.
static Short valueOf(String string, int radix)
Parses the string argument as if it was a short value and returns a Short representing the result.
static Short valueOf(String string)
Parses the string argument as if it was a short value and returns a Short representing the result.
static Short valueOf(short s)

Returns a Short instance for the short value passed.

[Expand]
Inherited Methods
From class java.lang.Number
From class java.lang.Object
From interface java.lang.Comparable

Constants

public static final short MAX_VALUE

Constant for the maximum short value, 215-1.

Constant Value: 32767 (0x00007fff)

public static final short MIN_VALUE

Constant for the minimum short value, -215.

Constant Value: -32768 (0xffff8000)

public static final int SIZE

Constant for the number of bits to represent a short in two's compliment form.

Constant Value: 16 (0x00000010)

public static final Class<Short> TYPE

The java.lang.Class that represents this class.

Public Constructors

public Short (String string)

Constructs a new instance of this class given a string.

Parameters
string a string representation of a short quantity.
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public Short (short value)

Constructs a new instance of the receiver which represents the short valued argument.

Parameters
value the short to store in the new instance.

Public Methods

public byte byteValue ()

Returns the byte value which the receiver represents

Returns
  • byte the value of the receiver.

public int compareTo (Short object)

Compares this Short to the Short passed. If this instance's value is equal to the value of the instance passed, then 0 is returned. If this instance's value is less than the value of the instance passed, then a negative value is returned. If this instance's value is greater than the value of the instance passed, then a positive value is returned.

Parameters
object The instance to compare to.
Throws
NullPointerException if object is null.

public static Short decode (String string)

Parses the string argument as if it was a short value and returns the result. Throws NumberFormatException if the string does not represent an int quantity. The string may be a hexadecimal ("0x..."), octal ("0..."), or decimal ("...") representation of a byte.

Parameters
string a string representation of a short quantity.
Returns
  • Short the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public double doubleValue ()

Returns the double value which the receiver represents

Returns
  • double the value of the receiver.

public boolean equals (Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

In this case, the argument must also be a Short, and the receiver and argument must represent the same short value.

Parameters
object the object to compare with this object
Returns
  • true if the object is the same as this object false if it is different from this object
See Also

public float floatValue ()

Returns the float value which the receiver represents

Returns
  • float the value of the receiver.

public int hashCode ()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Returns
  • the receiver's hash
See Also

public int intValue ()

Returns the int value which the receiver represents

Returns
  • int the value of the receiver.

public long longValue ()

Returns the long value which the receiver represents

Returns
  • long the value of the receiver.

public static short parseShort (String string)

Parses the string argument as if it was a short value and returns the result. Throws NumberFormatException if the string does not represent an short quantity.

Parameters
string a string representation of a short quantity.
Returns
  • short the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public static short parseShort (String string, int radix)

Parses the string argument as if it was a short value and returns the result. Throws NumberFormatException if the string does not represent a single short quantity. The second argument specifies the radix to use when parsing the value.

Parameters
string a string representation of a short quantity.
radix the radix to use when parsing.
Returns
  • short the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public static short reverseBytes (short s)

Reverses the bytes of a short.

Parameters
s The short to reverse.
Returns
  • The reversed value.

public short shortValue ()

Returns the short value which the receiver represents

Returns
  • short the value of the receiver.

public static String toString (short value)

Returns a string containing a concise, human-readable description of the argument.

Parameters
value short the short to convert.
Returns
  • String a printable representation for the short.

public String toString ()

Returns a string containing a concise, human-readable description of the receiver.

Returns
  • a printable representation for the receiver.

public static Short valueOf (String string, int radix)

Parses the string argument as if it was a short value and returns a Short representing the result. Throws NumberFormatException if the string does not represent a short quantity. The second argument specifies the radix to use when parsing the value.

Parameters
string a string representation of a short quantity.
radix the radix to use when parsing.
Returns
  • Short the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public static Short valueOf (String string)

Parses the string argument as if it was a short value and returns a Short representing the result. Throws NumberFormatException if the string does not represent a single short quantity.

Parameters
string a string representation of a short quantity.
Returns
  • Short the value represented by the argument
Throws
NumberFormatException if the argument could not be parsed as a short quantity.

public static Short valueOf (short s)

Returns a Short instance for the short value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.

Parameters
s The short value.
Returns
  • A Short instance.