Originally posted by Raj Kumar:
yes Keith Lynn ,
when we take this example
byte b = 127 +1;
compile won't say that the size can't fit into byte but it says the outcome of the above is an integer and we are trying to fit that to a byte .
By default, a whole number is considered to be an int.
There are cases where the compiler allows a direct assignment of an int to a byte.
But if you try this assignment
then the compiler will complain because what it sees is two ints being added together (even if the addends were bytes, they are going to be promoted to ints), and its not going to allow that to be assigned into a byte without a cast.