When you do mathematical operations on byte, Java do Widening( automatic type promotion) to byte(implicitly up casted) to integer this case. so when you perform
byte t3 = t1+t2; // t1+t2; will be evaluated as integer.
As t1+t2 result is wider than byte so you need to downcast it to byte.
To remove compilation error.
byte t3 = (byte) (t1+t2); // typecast to byte
For more information please read JLS 5.1.2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…