maclunian maclunian - 1 month ago 8
Java Question

What exactly does Double mean in java?

I'm extremely new to Java and just wanted to confirm what

Double
is? Is it similar to Float or Int? Any help would be appreciated. I also sometimes see the uppercase
Double
and other times the lower case
double
. If someone could clarify what this means that'd be great!

Answer

Double is a wrapper class,

The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.

In addition, this class provides several methods for converting a double to a String and a String to a double, as well as other constants and methods useful when dealing with a double.

The double data type,

The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative). For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.

Check each datatype with their ranges : Java's Primitive Data Types.


Important Note : If you'r thinking to use double for precise values, you need to re-think before using it. Java Traps: double