You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Double class in Java is a wrapper class for the primitive double type. It provides utility methods to work with double-precision floating-point numbers and is part of the java.lang package.
Key Features of the Double Wrapper Class
Boxing and Unboxing: Automatic conversion between primitive types and the Double wrapper class.
Constants: The class provides constants like MAX_VALUE, MIN_VALUE, POSITIVE_INFINITY, etc.
Utility Methods: Methods for parsing, converting, and performing mathematical operations on double values.
Double Wrapper Class Operations
Arithmetic Operations
Operation
Symbol
Example
Addition
+
doubleValue + doubleValue
Subtraction
-
doubleValue - doubleValue
Multiplication
*
doubleValue * doubleValue
Division
/
doubleValue / doubleValue
Modulo
%
doubleValue % doubleValue
Relational Operations
Operation
Symbol
Example
Equal to
==
doubleValue == doubleValue
Not equal to
!=
doubleValue != doubleValue
Greater than
>
doubleValue > doubleValue
Less than
<
doubleValue < doubleValue
Greater than or equal to
>=
doubleValue >= doubleValue
Less than or equal to
<=
doubleValue <= doubleValue
Static Methods
Method
Description
Example
compare(double d1, double d2)
Compares two double values.
Double.compare(3.2, 4.1) → Returns -1
parseDouble(String s)
Parses a String as a primitive double.
Double.parseDouble("3.14") → Returns 3.14
toHexString(double d)
Converts a double to its hexadecimal string representation.