2

This is fail.

int i = 2;
i = i -Double.MIN_VALUE;

But this is past

int i = 2;
i -= Double.MIN_VALUE;

Why can it be compiled?

I am using JDK 8

Surasin Tancharoen
  • 5,520
  • 4
  • 32
  • 40
  • There's an implicit cast when you use the `-=` operator, which makes the second snippet compile. – Tunaki Apr 10 '16 at 17:57
  • Have a look: http://stackoverflow.com/questions/8272635/why-does-java-perform-implicit-type-conversion-from-double-to-integer-when-using – user3046582 Apr 10 '16 at 17:58

0 Answers0