|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
java.lang.Short
public final class Short
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
.
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 |
---|
public static final short MIN_VALUE
short
can
have, -215.
public static final short MAX_VALUE
short
can
have, 215-1.
Constructor Detail |
---|
public Short(short s)
Short
object that
represents the specified short
value.
s
- the value to be represented by the
Short
.Method Detail |
---|
public byte byteValue()
Short
as a
byte
.
byteValue
in class Number
byte
.public short shortValue()
Short
as a
short
.
shortValue
in class Number
short
.public int intValue()
Short
as an
int
.
intValue
in class Number
int
.public long longValue()
Short
as a
long
.
longValue
in class Number
long
.public double doubleValue()
Short
as a
double
.
doubleValue
in class Number
double
.public float floatValue()
Short
as a
float
.
floatValue
in class Number
float
.public String toString()
toString
in class Object
public static short parseShort(String s) throws NumberFormatException
s
- the String containing the short
NumberFormatException
- 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 used
NumberFormatException
- If the String does not
contain a parsable short.public int hashCode()
Object
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
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.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
Object
The equals
method implements an equivalence relation:
x
,
x.equals(x)
should return true
.
x
and
y
, x.equals(y)
should return
true
if and only if y.equals(x)
returns
true
.
x
,
y
, and z
, if x.equals(y)
returns true
and y.equals(z)
returns
true
, then x.equals(z)
should return
true
.
x
and y
, multiple invocations of x.equals(y)
consistently return true
or consistently return
false
, provided no information used in
equals
comparisons on the object is modified.
x
,
x.equals(null)
should return false
.
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
).
equals
in class Object
obj
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.Boolean.hashCode()
,
Hashtable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |