I have a rather simple - but for me confusing - question. Assume the byte variabels a,b,c:
byte a = 5;
byte b = 3;
byte c = a + b; // wont compile
Line 3 wont compile because - I suppose - Java has to make a calculation behind the scenes and the outcome of the calculation is an integer. An integer can't be passed to a byte without explicit casting. So (byte)(a+b) should have been provided. But now assume there is a 4th line of code with an explicit cast to integer ...
c = (int) 8 ; // compiles
It compiles although the byte variabel 'c' is explicitly casted to integer. How is Java handling this aspect ... ?