|
APCS Java Subset | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectap.java.lang.Double
The class Double
is an immutable wrapper class for
the primitive type double
, allowing primitive values
in some contexts to be treated as objects.
The four methods below are those specified in the APCS Java
subset for the wrapper class Double
. An object
whose type is Double
encapsulates a single
double
value. The methods in the APCS Java subset
are applicable to Double
objects. Two static methods
not in the subset are often useful in practice. These
methods, parseDouble
and toString
are
shown in use in the following code.
String s = Double.toString(3.14159); // s is "3.14159" double d = Double.parseDouble("123.45") // d is 123.45
Constructor Summary | |
Double(double value)
Constructs an immutable Double wrapping value. |
Method Summary | |
int |
compareTo(Object other)
Compares two Double objects and returns
a value consistent with the contract of
Comparable.compareTo and with the value
returned by Double.equals . |
double |
doubleValue()
Returns the value represented by this object. |
boolean |
equals(Object other)
Determines if this Double object is equal to
another. |
String |
toString()
Returns a representation of this object as a string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Double(double value)
Double
wrapping value.
value
- is the value wrapped by this objectMethod Detail |
public double doubleValue()
double
value represented by
this objectpublic boolean equals(Object other)
Double
object is equal to
another. In general, this method returns true if and only
if this.doubleValue() == other.doubleValue()
.
However, if both of the values are Double.NaN
then
this method returns true
(see the standard Java API) and
if one of the objects is +0.0
and the other
is -0.0
then this method returns
true
.
other
- is the other Double
object to which
this one is compared
other
.public String toString()
Double
object.public int compareTo(Object other)
Double
objects and returns
a value consistent with the contract of
Comparable.compareTo
and with the value
returned by Double.equals
.
compareTo
in interface Comparable
other
- is the Double
object to which this
one is compared
other
, a value less than 0 if this object is less
than other
, and a value greater than 0 if this
object is greater than other
|
unofficial documentation for the APCS Java Subset | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |