Why does Java perform implicit type conversion from double to integer when using the "plus equals" operator?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2696812/varying-behavior-for-possible-loss-of-precision">Varying behavior for possible loss of precision</a>  </p>
</blockquote>



<p>Code Sample A</p>

<pre><code> public class Test {                                                         
     public static void main(String[] args) {
         int i = 0;
         i = i + 1.5;
     }
 }
</code></pre>

<p>Code Sample B</p>

<pre><code> public class Test {                                                         
     public static void main(String[] args) {
         int i = 0;
         i += 1.5;
     }
 }
</code></pre>

<p>Unsurprisingly, compiling A produces the error below. <strong>Surprisingly</strong>, compiling B produces no error and it appears to behave as if I inserted an explicit cast to integer before the double value 1.5.  Why in the world does this happen?  This goes against everything I thought I knew!</p>

<pre><code>Test.java:6: possible

 loss of precision

    found   : double
    required: int
            i = i + 1.5;
                  ^
    1 error
</code></pre>
