byte b=127; byte c=126; byte d=b-c; In the third line the compiler complains . It seams that the result is casted to int implicitly when two number calculate, but why? And are there any other cases do the implicit cast appears ?
From Kathy/Bert 's book, page 148-149: "the result of an expression involving anything int-sized or smaller is always an int. In other words, add two bytes together and you'll get an int." So the compiler will complain that it can't convert int to byte, you need to explicit case to byte.
SCJP2 1.4 (96%) SCWCD(96%)
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads