It is valid because it is an expression of a compile-time constant. If it were
char x; char y = 'A'; x = y + 1;
The compiler will give you a compile-time error, because now it is not an expression of the compile-time constant. But if you make the variable y as final , the expression will again return to the compile-time constant, so the code below will compile.
char x; final char y = 'A'; x = y + 1;
The moral of the story is that when you assign an integer to char, the compiler will resolve it as long as it is a compiler time constant, and it must match the char range.
source share