You would call doubleValue if you need to get double from double . The former is a primitive type, and the latter is a wrapper object type that basically encapsulates a primitive value inside an immutable object. If possible (and I say this without knowing exactly the purpose of your code), use double for all your calculations; use only double if you need to save values ββin Collection or Map ; that, since object types consume more memory and can be casted.
It's easy to accept double with double (the same applies to other primitive types versus wrapper types), since the compiler will automatically convert from one to another as necessary in a process known as automatic boxing (and automatic unpacking), so a little take care to use the correct type.
source share