-3
I was making a code and, by mistake, I put double
and the IDE accepted, I always used with the D capital.
What’s the difference between the two?
-3
I was making a code and, by mistake, I put double
and the IDE accepted, I always used with the D capital.
What’s the difference between the two?
11
The class Double
involves a primitive type value double
on an object. An object of the type Double
contains a single field whose type is double
.
In addition, this class provides several methods to convert a double
in a String
and a String
in a double
, as well as other constants and methods useful in dealing with a double
.
Source: https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html
In summary, the classe Double
is a wrapper
.
See more about Wrappers
here.
5
double
is a type of primitive data (i.e., it is not created by reference, in other words, it is not an object). Not being an object, you don’t have access to a number of facilities that object manipulation offers, perhaps the most important being the conversion of a value double
text-based (String
) and the use of collections (ArrayList
, Set
etc.), since they only deal with objects and not primitive ones.
To make it possible for primitive types to make use of the resources that objects have at their disposal, in Java, for each primitive type there exists a class whose only function is to receive the value of it and to "pack" the value of that primitive with an object. These classes are called Wrappers (packers). As in Java, the default class nomenclature is uppercase first letter, the class wrapper of the primitive double
is the Double
.
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Related:What difference between Boolean and Boolean?
– user28595
Related: int and Integer - Java
– user28595