- char c = '1';
- char res = '0' + '1'; // no error
- char res2 = '0' + c; // compile error
The last line will throw compile error. Each part of the expression is char, why the expression itself is promoted to an int?
Thanks
Edit: Found why the 3rd statement failed. The reason is explained in In Java, is the result of the addition of two chars an int or a char?
But the knowledge that char + char = int does not explain why the 2nd of your three examples does compile. Any ideas?