Java Double class
Last Updated : 17 Mar 2025
The Double class generally wraps the primitive type double into an object. An object of Double class contains a field with the type Double.
Methods:
This class is useful in providing various methods like a method which can be used to convert a double to a String and a method which can be used to convert a String into a double.
| Methods | Description |
|---|---|
| byteValue() | It returns the value of Double as a byte after the conversion. |
| compare(double d1, double d2) | It compares the two double values. |
| compareTo(Double another Double) | It compares two Double objects numerically. |
| DoubleToLongBits(double value) | It returns the representation of the floating point value provided by IEEE 754 "double format" bit layout. |
| doubleToRawLongBits(double value) | It returns the representation of the floating point value provided by IEEE 754 "double format" bit layout. |
| doubleValue() | It returns the value of Double as a double after the conversion. |
| equals(Object obj) | It compares the object with the specified object. |
| floatValue() | It returns the float type value for the given Double object. |
| hashCode() | It returns the hash code for the given Double object. |
| hashCode(Double value) | It returns the hash code for the given Double value. |
| intValue() | It returns the value of Double as an int after the conversion. |
| isFinite(double d) | It returns true if the argument is finite floating point. Otherwise, returns false. |
| isInfinite() | It returns true if the double value is infinitely large in magnitude. Otherwise, returns false. |
| isInfinite(double v) | It returns true if the given number is infinitely large in magnitude. Otherwise, returns false. |
| isNaN() | It returns true if the double value is Not a Number value. Otherwise, returns false. |
| IsNaN(double v) | It returns true if the specified number is Not a Number value. Otherwise, returns false. |
| longBitsToDouble(long bits) | It returns the value of type Double in correspondence to the given bit representation. |
| longValue() | It returns the value of Double as a long after the conversion. |
| max(double a, double b) | It returns the greater of the two double values. |
| min(double a, double b) | It returns the smaller of the two double values. |
| parseDouble(String s) | It returns a new double which is initialized by the value provided by the String. |
| shortValue() | It returns the value of Double as a short after the conversion. |
| sum(double a, double b) | It adds the two values as per the + operator. |
| toHexString(double d) | It returns a hexadecimal string represented by the double argument. |
| toString() | It returns a string represented by the Double object. |
| toString(double d) | It returns a string represented by the double argument. |
| valueOf(double d) | It returns the object of Double represented by a double value. |
| valueOf(String s) | It returns the object of Double which holds the double value represented by string argument. |
Example 1
Output:
The hashCode for the number '45.0' is given as :1078362112 The interger type value for the double '67.0' is given as :67 Is the number 'NaN' is NaN? :true Is the number '67.0' is finite? true
Example 2
Output:
The first value is : 59.0 The second value is : 90.0 The value '90.0' is the greatest. The maximum of the two values '59.0' and '90.0' is given as :90.0
Next TopicJava-double-bytevalue-method
Subscribe to Tpoint Tech
We request you to subscribe our newsletter for upcoming updates.