The +
operator for char
is defined as the sum of their integer values, resulting in an integer.
Because you ask about ASCII, we have to explain the sum this way…
A Java char
holds a UTF-16 code-unit value, UTF-16 is an encoding for Unicode, Unicode is a superset of ASCII and UTF-16 encodes characters in the common subset with the same values as ASCII does, and in this code the size of a UTF-16 code-unit (two bytes) being different than the size of an ASCII code-unit (one byte) doesn't matter.
So, when you sum two char
values that hold characters in the ASCII subset, the sum is the same as summing their ASCII values.