Explicit type casting vs using suffix for float/double Java - difference?
<p>Based on the snippet below:</p>

<pre><code>    // as primitive
    MyClass.primitiveMethod(double val); // method signature
    MyClass.primitiveMethod(12);         // ok

    // as object
    MyClass.objectMethod(Double val); // method signature
    MyClass.objectMethod(12);         // error
    MyClass.objectMethod(12d);        // ok
    MyClass.objectMethod((double)12); //ok
</code></pre>

<p>Q1: While both <code>12d</code> and <code>(double)12</code> seem to work, are there any difference between specifying suffix and explicit casting? (behaviour/performance)</p>

<p>Q2: Why <code>MyClass.objectMethod(12)</code> must be considered an error? While 12 is supposed to be resolved to an Integer object, can't Java be smart enough to know that 12 is also a value Double value and just accept it?</p>
