Short

Name

Short

Synopsis

Description

The Short class provides an object wrapper for a short value. This is useful when you need to treat a short value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a short value for one of these arguments, but you can provide a reference to a Short object that encapsulates the byte value. Furthermore, the Short class is necessary as of JDK 1.1 to support the Reflection API and class literals.

The Short class also provides a number of utility methods for converting short values to other primitive types and for converting short values to strings and vice-versa.

Class Summary

public final class java.lang.Short extends java.lang.Number {
 // Constants public static final short MAX_VALUE;
public static final short MIN_VALUE;
public static final Class TYPE; // Constructors public Short(short value);
public Short(String s); // Class Methods public static Short decode(String nm);
public static short parseShort(String s);
public static short parseShort(String s, int radix);
public static String toString(short s);
public static Short valueOf(String s, int radix);
public static Short valueOf(String s); // Instance Methods public byte byteValue();
public double doubleValue();
public boolean equals(Object obj);
public float floatValue();
public int hashCode();
public int intValue();
public long longValue();
public short shortValue();
public String toString();
}

Constants

MAX_VALUE

public static final short MAX_VALUE= 32767

The largest value that can be represented by a short.

MIN_VALUE

public static final byte MIN_VALUE= -32768

The smallest value that can be represented by a short.

TYPE

public static final Class TYPE

The Class object that represents the primitive type short. It is always true that Short.TYPE == short.class.

Constructors

Short

public Short(short value)

public Short(String s) throws NumberFormatException

Class Methods

decode

public static Short decode(String nm) throws NumberFormatException

parseByte

public static short parseShort(String s) throws NumberFormatException 

public static short parseShort(String s, int radix) throws NumberFormatException 

toString

public String toString(short s)

valueOf

public static Short valueOf(String s) throws NumberFormatException

public static Short valueOf(String s, int radix) throws NumberFormatException 

Instance Methods

byteValue

public byte byteValue()

doubleValue

public double doubleValue()

equals

public boolean equals(Object obj)

floatValue

public float floatValue()

hashCode

public int hashCode()

intValue

public int intValue()

longValue

public long longValue()

shortValue

public short shortValue()

toString

public String toString()

Inherited Methods

Method Inherited From Method Inherited From
clone() Object finalize() Object
getClass() Object notify() Object
notifyAll() Object wait() Object
wait(long) Object wait(long, int) Object

See Also

Byte; Character; Class; Double; Exceptions; Float; Integer literals; Integer types; Integer; Long; Number; String