The Java specification says:
Furthermore, if the expression is a constant expression (Β§15.28) such as a byte, short, char or int:
Narrowing the primitive conversion can be used if the type of the variable is byte, short, or char, and the value of the constant expression is represented in the type of the variable.
Char has a minimum value of 0 and a maximum value of 65,535.
A short value has a minimum value of -32,768 and a maximum value of 32,767.
An integer has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647.
So char can fit into an integer, but not a short one, so you have to assure java that you want to make typecast here.
source share