- In line bal = ((Double)balance.get("John Doe")).doubleValue(); what is the use of doubleValue (know it converts object to double value )
but program runs okay if i run without this.
Correct.
- (correct me if I am wrong)
balance.get()
gets a double object of value 3434.34 and (double) in front of it does unboxing
No. There is no (double)
. There is (Double)
. That typecasts it from Object
to Double
.
and converts it into double object
Yes.
in double value
No. It is an object not a value. This phrase is meaningless.
then how and why does doubleValue() treats this double 3434.34 as object?
It doesn't. It calls Double.doubleValue() which returns a double
.
This code doesn't use autoboxing at all. The doublevalue()
calls in this code have been obsolete since Java 1.5 came out about 5 years ago. It also doesn't use Generics. I suspect you are looking at some very old code.