java.lang
Class Short

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Short
All Implemented Interfaces:
Serializable

public final class Short
extends Number

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.

See Also:
Serialized Form

Field Summary
static short MAX_VALUE
          A constant holding the maximum value a short can have, 215-1.
static short MIN_VALUE
          A constant holding the minimum value a short can have, -215.
 
Constructor Summary
Short(short s)
          Constructs a newly allocated Short object that represents the specified short value.
 
Method Summary
 byte byteValue()
          Returns the value of this Short as a byte.
 double doubleValue()
          Returns the value of this Short as a double.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 float floatValue()
          Returns the value of this Short as a float.
 int hashCode()
          Returns a hash code value for the object.
 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)
          Assuming the specified String represents a short, returns that short's value.
static short parseShort(String s, int radix)
          Assuming the specified String represents a short, returns that short's value in the radix specified by the second argument.
 short shortValue()
          Returns the value of this Short as a short.
 String toString()
          Returns a String object representing this Short's value.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final short MIN_VALUE
A constant holding the minimum value a short can have, -215.

See Also:
Constant Field Values

MAX_VALUE

public static final short MAX_VALUE
A constant holding the maximum value a short can have, 215-1.

See Also:
Constant Field Values
Constructor Detail

Short

public Short(short s)
Constructs a newly allocated Short object that represents the specified short value.

Parameters:
s - the value to be represented by the Short.
Method Detail

byteValue

public byte byteValue()
Returns the value of this Short as a byte.

Specified by:
byteValue in class Number
Returns:
the numeric value represented by this object after conversion to type byte.

shortValue

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

Specified by:
shortValue in class Number
Returns:
the numeric value represented by this object after conversion to type short.

intValue

public int intValue()
Returns the value of this Short as an int.

Specified by:
intValue in class Number
Returns:
the numeric value represented by this object after conversion to type int.

longValue

public long longValue()
Returns the value of this Short as a long.

Specified by:
longValue in class Number
Returns:
the numeric value represented by this object after conversion to type long.

doubleValue

public double doubleValue()
Returns the value of this Short as a double.

Specified by:
doubleValue in class Number
Returns:
the numeric value represented by this object after conversion to type double.

floatValue

public float floatValue()
Returns the value of this Short as a float.

Specified by:
floatValue in class Number
Returns:
the numeric value represented by this object after conversion to type float.

toString

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

Overrides:
toString in class Object
Returns:
a string representation of the object.

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.

Parameters:
s - the String containing the short
Returns:
The short value represented by the specified string
Throws:
NumberFormatException - If the string does not contain a parsable short.

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.

Parameters:
s - the String containing the short
radix - the radix to be used
Returns:
The short value represented by the specified string in the specified radix.
Throws:
NumberFormatException - If the String does not contain a parsable short.

hashCode

public int hashCode()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

equals

public boolean equals(Object obj)
Description copied from class: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Boolean.hashCode(), Hashtable


Copyright © 2007 Sentilla Corporation. All Rights Reserved.