Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Short

  1. Object
  2. Number
  3. Short

ImplementsComparable<Short>

The Short class is the standard wrapper for short values. Since: JDK1.1, CLDC 1.0

Fields

public static final short MAX_VALUE = 32767The maximum value a Short can have.
public static final short MIN_VALUE = -32768The minimum value a Short can have.
public static final Class<Short> TYPE
public static final int BYTES = 2The size of a short in bytes.
public static final int SIZE = 16The size of a short in bits.

Constructors

public Short(short value)Constructs a Short object initialized to the specified short value.
public Short(String s) throws NumberFormatExceptionDeprecated A Short of parseShort(s).

Methods

public boolean equals(Object obj)Compares this object to the specified object.
public int hashCode()Returns a hashcode for this Short.
public static short parseShort(String s) throws NumberFormatExceptionAssuming the specified String represents a short, returns that short’s value.
public static short parseShort(String s, int radix) throws NumberFormatExceptionAssuming the specified String represents a short, returns that short’s value in the radix specified by the second argument.
public short shortValue()Returns the value of this Short as a short.
public String toString()Returns a String object representing this Short’s value.
public static Short valueOf(short i)Returns the object instance of i
public int intValue()
public long longValue()
public float floatValue()
public double doubleValue()
public int compareTo(Short another)Compares this object to the specified object to determine their relative order.
public static int compare(short s1, short s2)
public static String toString(short s)The decimal string of s.
public static Short valueOf(String s) throws NumberFormatExceptionA Short of parseShort(s).
public static Short valueOf(String s, int radix) throws NumberFormatExceptionA Short of parseShort(s, radix).
public static Short decode(String nm) throws NumberFormatExceptionDecodes a decimal, hexadecimal or octal short, as Integer.decode.
public static int hashCode(short value)The value itself.
public static int compareUnsigned(short x, short y)Compares the two as unsigned values.
public static int toUnsignedInt(short x)The value as an unsigned int.
public static long toUnsignedLong(short x)The value as an unsigned long.
public static short reverseBytes(short i)The bytes in reverse order.

Inherited methods

Field details

MAX_VALUE

public static final short MAX_VALUE = 32767
The maximum value a Short can have. See Also:Constant Field Values

MIN_VALUE

public static final short MIN_VALUE = -32768
The minimum value a Short can have. See Also:Constant Field Values

TYPE

public static final Class<Short> TYPE

BYTES

public static final int BYTES = 2
The size of a short in bytes.

SIZE

public static final int SIZE = 16
The size of a short in bits.

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

public Short(String s) throws NumberFormatException
Deprecated.
A Short of parseShort(s).

Method details

equals

public boolean equals(Object obj)
Compares this object to the specified object.

hashCode

public int hashCode()
Returns a hashcode for this Short.

parseShort

public static short parseShort(String s) throws NumberFormatException
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.

parseShort

public static short parseShort(String s, int radix) throws NumberFormatException
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.

shortValue

public short shortValue()
Returns the value of this Short as a short.

toString

public String toString()
Returns a String object representing this Short’s value.

valueOf

public static Short valueOf(short i)
Returns the object instance of i

Parameters

i short
the primitive

Returns

object instance

intValue

public int intValue()

longValue

public long longValue()

floatValue

public float floatValue()

doubleValue

public double doubleValue()

compareTo

public int compareTo(Short another)
Compares this object to the specified object to determine their relative order.

Parameters

another Short
the object to compare to this instance.

Returns

a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.

Throws

ClassCastException
if another cannot be converted into something comparable to this instance.

compare

public static int compare(short s1, short s2)

toString

public static String toString(short s)
The decimal string of s.

valueOf

public static Short valueOf(String s) throws NumberFormatException
A Short of parseShort(s).

valueOf

public static Short valueOf(String s, int radix) throws NumberFormatException
A Short of parseShort(s, radix).

decode

public static Short decode(String nm) throws NumberFormatException
Decodes a decimal, hexadecimal or octal short, as Integer.decode.

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.