I'm reading java OCA certification documentation. Some primitive operations behavior seems realy strange for me.
it is said that all byte, short and char value are automatically widening to int when used as operand for arithmetic operations. this is perfectily logic. but confusion come when we make this operands final.
this code will not compile (logic)
short s1 = 10 ;
short s2 = 20 ;
short sum = s1 + s2;
but this one will compile
final short s1 = 10 ;
final short s2 = 20 ;
short sum = s1 + s2;
Why this will compil successfuly? what property of the keyword final make this code compile?