Originally posted by Anup Engineer:
* If the operand is a byte, a short, or a char, it is converted to an int (unless the operator is ++ or --, in which case no conversion happens).
Didn't you write this yourself?
And you don't believe your own writing?
There is no conversion necessary here:
char c = 'j';
c++;
c is of type char, but don't forget that char is an integer type (Not
int, integer, as opposed to floating point.) It's a 16 bit quantity. Adding one to it is something easily done without the need to convert it. This is one of those special cases you need to remember.
The following, however, causes the result to be converted to an int:
c +=1;
However, it's also implicitly narrowed back to a char for you!
But this will result in a compiler error:
c = c + 1; //must explicitly cast result type back to char