|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Number | +--java.lang.Short
The Short class is the standard wrapper for short values.
Number
, Serialized FormField Summary | |
static short |
MAX_VALUE
The maximum value a Short can have. |
static short |
MIN_VALUE
The minimum value a Short can have. |
static Class |
TYPE
The Class object representing the primitive type short. |
Constructor Summary | |
Short(short value)
Constructs a Short object initialized to the specified short value. |
|
Short(String s)
Constructs a Short object initialized to the value specified by the String parameter. |
Method Summary | |
byte |
byteValue()
Returns the value of this Short as a byte. |
int |
compareTo(Object o)
Compares this Short to another Object. |
int |
compareTo(Short anotherShort)
Compares two Shorts numerically. |
static Short |
decode(String nm)
Decodes a String into a Short . |
double |
doubleValue()
Returns the value of this Short as a double. |
boolean |
equals(Object obj)
Compares this object to the specified object. |
float |
floatValue()
Returns the value of this Short as a float. |
int |
hashCode()
Returns a hashcode for this Short. |
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. |
short |
shortValue()
Returns the value of this Short as a short. |
String |
toString()
Returns a String object representing this Short's value. |
static String |
toString(short s)
Returns a new String object representing the specified Short. |
static Short |
valueOf(String s)
Assuming the specified String represents a short, returns a new Short object initialized to that value. |
static Short |
valueOf(String s,
int radix)
Assuming the specified String represents a short, returns a new Short object initialized to that value. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final short MIN_VALUE
public static final short MAX_VALUE
public static final Class TYPE
Constructor Detail |
public Short(short value)
value
- the initial value of the Shortpublic Short(String s) throws NumberFormatException
s
- the String to be converted to a ShortNumberFormatException
- If the String does not
contain a parsable short.Method Detail |
public static String toString(short s)
s
- the short to be convertedpublic static short parseShort(String s) throws NumberFormatException
s
- the String containing the shortNumberFormatException
- If the string does not
contain a parsable short.public static short parseShort(String s, int radix) throws NumberFormatException
s
- the String containing the shortradix
- the radix to be usedNumberFormatException
- If the String does not
contain a parsable short.public static Short valueOf(String s, int radix) throws NumberFormatException
s
- the String containing the integerradix
- the radix to be usedNumberFormatException
- If the String does not
contain a parsable short.public static Short valueOf(String s) throws NumberFormatException
s
- the String containing the integerNumberFormatException
- If the String does not
contain a parsable short.public static Short decode(String nm) throws NumberFormatException
String
into a Short
. Accepts
decimal, hexadecimal, and octal numbers, in the following formats:
[-] decimal constant [-] 0x hex constant [-] # hex constant [-] 0 octal constantThe constant following an (optional) negative sign and/or "radix specifier" is parsed as by the
Short.parseShort
method
with the specified radix (10, 8 or 16). This constant must be positive
or a NumberFormatException will result. The result is made negative if
first character of the specified String
is the negative
sign. No whitespace characters are permitted in the
String
.nm
- the String
to decode.Short
represented by the specified string.NumberFormatException
- if the String
does not
contain a parsable short.parseShort(String, int)
public byte byteValue()
byteValue
in class Number
java.lang.Number
byte
.public short shortValue()
shortValue
in class Number
java.lang.Number
short
.public int intValue()
intValue
in class Number
java.lang.Number
int
.public long longValue()
longValue
in class Number
java.lang.Number
long
.public float floatValue()
floatValue
in class Number
java.lang.Number
float
.public double doubleValue()
doubleValue
in class Number
java.lang.Number
double
.public String toString()
toString
in class Object
java.lang.Object
public int hashCode()
hashCode
in class Object
java.lang.Object
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
equals
in class Object
obj
- the object to compare withpublic int compareTo(Short anotherShort)
anotherShort
- the Short
to be compared.0
if the argument Short is equal to
this Short; a value less than 0
if this Short
is numerically less than the Short argument; and a
value greater than 0
if this Short is
numerically greater than the Short argument
(signed comparison).public int compareTo(Object o)
compareTo(Short)
. Otherwise,
it throws a ClassCastException
(as Shorts are comparable
only to other Shorts).compareTo
in interface Comparable
o
- the Object
to be compared.0
if the argument is a Short
numerically equal to this Short; a value less than
0
if the argument is a Short numerically
greater than this Short; and a value greater than
0
if the argument is a Short numerically
less than this Short.ClassCastException
- if the argument is not a
Short
.Comparable
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Oracle and/or its affiliates, in the US and other countries.
Copyright © 1995, 2010 Oracle and/or its affiliates. All rights reserved.