aicas logoJamaica 6.4 release 1

java.lang
Class Short

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Short
All Implemented Interfaces:
Serializable, Comparable<Short>

public final class Short
extends Number
implements Comparable<Short>

Short provides a class for short values stored in objects.

Since:
1.1
See Also:
Serialized Form

Field Summary
static short MAX_VALUE
          The largest value a short can hold.
static short MIN_VALUE
          The smallest value a short can hold.
static int SIZE
          The size occupied by one short in bits.
static Class<Short> TYPE
          type for short.
 
Constructor Summary
Short(short value)
          Constructor to create an instance of Short with the given short value.
Short(String s)
          Constructor to create an instance of Short with the value provided as a string.
 
Method Summary
 byte byteValue()
          byteValue returns the value of this as a byte.
 int compareTo(Short o)
          compareTo compares this to another short value
static Short decode(String nm)
          decode parses a short given as a decimal, octal or hex number.
 double doubleValue()
          doubleValue returns the value of this as a double.
 boolean equals(Object obj)
          equals checks if this and obj represent the same value.
 float floatValue()
          floatValue returns the value of this as a float.
 int hashCode()
          hashCode returns a hashCode for this Short.
 int intValue()
          intValue returns the value of this as an int.
 long longValue()
          longValue returns the value of this as a long.
static short parseShort(String s)
          parseShort parses a string that contains the decimal representation of a short and returns the short's value.
static short parseShort(String s, int radix)
          parseShort parses a string that contains a short represented by a number using the given radix.
static short reverseBytes(short s)
          reverseBytes returns a short with reversed bytes of s.
 short shortValue()
          shortValue returns the value of this as a short.
 String toString()
          toString converts the value of this int to a decimal string.
static String toString(short s)
          toString creates a decimal string from the given short value.
static Short valueOf(short s)
          valueOf returns a short instance with the given value.
static Short valueOf(String s)
          valueOf returns a short instance with the value given as a decimal string.
static Short valueOf(String s, int radix)
          valueOf returns a short instance with the value given as a string with given radix.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final short MIN_VALUE
The smallest value a short can hold.

See Also:
Constant Field Values

MAX_VALUE

public static final short MAX_VALUE
The largest value a short can hold.

See Also:
Constant Field Values

SIZE

public static final int SIZE
The size occupied by one short in bits.

Since:
1.5
See Also:
Constant Field Values

TYPE

public static final Class<Short> TYPE
type for short.

Since:
1.1
Constructor Detail

Short

public Short(short value)
Constructor to create an instance of Short with the given short value.

Parameters:
value - the value for this instance.

Short

public Short(String s)
      throws NumberFormatException
Constructor to create an instance of Short with the value provided as a string.

Parameters:
s - the string representation of the value.
Throws:
NumberFormatException - if s could not be parsed as a short.
Method Detail

toString

public static String toString(short s)
toString creates a decimal string from the given short value.

Parameters:
s - the short value
Returns:
the corresponding decimal string, e.g. "-128", "3", "127".

parseShort

public static short parseShort(String s)
                        throws NumberFormatException
parseShort parses a string that contains the decimal representation of a short and returns the short's value.

Parameters:
s - the string, e.g, "-128", "3", "127".
Returns:
the short value.
Throws:
NumberFormatException - if s is not parsable or out of the legal range for shorts.

parseShort

public static short parseShort(String s,
                               int radix)
                        throws NumberFormatException
parseShort parses a string that contains a short represented by a number using the given radix. Returns the short's value.

Parameters:
s - the string
radix - the radix
Returns:
the short value.
Throws:
NumberFormatException - if s is not parsable, radix is out of the legal range or the value is out of the legal range for shorts.

valueOf

public static Short valueOf(String s,
                            int radix)
                     throws NumberFormatException
valueOf returns a short instance with the value given as a string with given radix. A cache is used to avoid multiple allocations of the same Short instance.

Parameters:
s - the string
radix - the radix
Returns:
a Short instance with the given value.
Throws:
NumberFormatException - if s is not parsable, radix is out of the legal range or the value is out of the legal range for shorts.

valueOf

public static Short valueOf(String s)
                     throws NumberFormatException
valueOf returns a short instance with the value given as a decimal string. A cache is used to avoid multiple allocations of the same Integer instance.

Parameters:
s - the string, e.g, "-128", "3", "127".
Returns:
a Short instance with the given value.
Throws:
NumberFormatException - if s is not parsable or the value is out of the legal range for shorts.

decode

public static Short decode(String nm)
                    throws NumberFormatException
decode parses a short given as a decimal, octal or hex number. Prefix for hex is 0x, #, -0x or -#, for octal is 0 of -0.

Parameters:
nm - the short value as a string
Returns:
the corresponding short value.
Throws:
NumberFormatException - if parsing failed or the resulting value is not representable as a short.
Since:
1.2

byteValue

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

Overrides:
byteValue in class Number
Returns:
the value converted to byte.

shortValue

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

Overrides:
shortValue in class Number
Returns:
the value converted to short.

intValue

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

Specified by:
intValue in class Number
Returns:
the value converted to int.

longValue

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

Specified by:
longValue in class Number
Returns:
the value converted to long.

floatValue

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

Specified by:
floatValue in class Number
Returns:
the value converted to float.

doubleValue

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

Specified by:
doubleValue in class Number
Returns:
the value converted to double.

toString

public String toString()
toString converts the value of this int to a decimal string.

Overrides:
toString in class Object
Returns:
the string, e.g. "-128", "127", "3".

hashCode

public int hashCode()
hashCode returns a hashCode for this Short.

Overrides:
hashCode in class Object
Returns:
the short value converted to int.

equals

public boolean equals(Object obj)
equals checks if this and obj represent the same value.

Overrides:
equals in class Object
Parameters:
obj - another object
Returns:
true of obj is a Short that represents the same value as this.

compareTo

public int compareTo(Short o)
compareTo compares this to another short value

Specified by:
compareTo in interface Comparable<Short>
Parameters:
o - the other short
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is larger than o.
Since:
1.2

valueOf

public static Short valueOf(short s)
valueOf returns a short instance with the given value. A cache is used to avoid multiple allocations of the same Short instance.

Parameters:
s - the short value
Returns:
an instance with value equal to s.
Since:
1.5

reverseBytes

public static short reverseBytes(short s)
reverseBytes returns a short with reversed bytes of s.

Parameters:
s - the short value
Returns:
a short with swapped bytes.
Since:
1.5

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.