This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Not exactly the + operator, but rather that all operands in an expression
are promoted to at least type int before the operation is done. The same
error occurs if you assign (long + byte) to an int.
Jim ... ...
BEE MBA PMP SCJP-6
Joined: Sep 12, 2009
@ Tayitu Betule
Thanks Sir, but i just want to add a bit correction
(byte) a+b would not work.
(byte) (a+b) would work !!!
Joined: Jan 09, 2008
Yes, because the casting operation takes precedence over the + operator. With
((byte) a + b), only a is cast to byte. Then both a and b are promoted to int before
the add. The result must be explecitly downcast to be considered a byte (or short).