In Java, you can cast char to int and vice-versa, using the char value or the ASCII value. If you cast an int variable to a char, you get the corresponding character. So, the following snippet will print 'a':
int x = 97;
System.out.println( (char)x ); // 'a'
But when I do this:
char ch = 'a', ch2 = 97, ch3 = 'b';
System.out.println( ( (ch+=1) > ch2 ) ? (char)ch2 : (int)ch3 );
the compiler prints out the int value 97, not 'a', even though the ternary operator return value on the 'true side' is (char)ch2. So I expected 'a' instead of 97. Why does it print 97 instead of 'a'?