Compilation error: casting.

Posted by Andrei Ciobanu on Stack Overflow See other posts from Stack Overflow or by Andrei Ciobanu
Published on 2010-05-03T07:36:34Z Indexed on 2010/05/03 7:48 UTC
Read the original article Hit count: 311

Filed under:

Can somebody explain me why the following piece of code fails to compile. The error is: "Possible loss of precision." :

byte a = 50;
byte b = 40;
byte sum = (byte)a + b;
System.out.println(sum);

Thank you.

© Stack Overflow or respective owner

Related posts about java