// Method A
public static void foo(Double d) {...}
// Method B
public static void foo(double d) {...}
Evidently, if you pass a Double
object then Method A will be called; i.e. if you had something like:
Double d = new Double(1.0);
Further, if you pass a double literal you will call Method B. What's interesting is if you have something like
double d = new Double(1.0);
In this case Method B will also be called, because the type of d
is double
; the Double
object gets unboxed to a double
. On the same note, if you had:
Double d = 1.0;
then Method A would be called, because the type of d
would be Double
(the double
-literal gets autoboxed to a Double
).