If I define a single method, for all your example then too it compiles and produce result as expected without any errors
public static double add(double i , double j)
{
return i + j;
}
This phenomena of Boxing Unboxing is neatly handled by Java compiler.