I know that during java arithmetic operations data types like byte,short,and char values are automatically widened to int ,I understand why the following example fails to compile :
byte a = 10 ;
byte b = 20 ; // compile fails
short sum = a + b ;
But what I didn't understand if we modify the preceding example and define variables a and b as final then its compiles successfully :
final byte a = 10 ;
final byte b = 20 ; // compile successful
short sum = a + b ;
What I didn't understand here is how the key final assure the compiler to do the sum ?