Why does ('1'+'1') output 98 in Java? [duplicate]
问题 This question already has answers here : In Java, is the result of the addition of two chars an int or a char? (8 answers) Closed 3 months ago . I have the following code: class Example{ public static void main(String args[]){ System.out.println('1'+'1'); } } Why does it output 98 ? 回答1: In java, every character literal is associated with an ASCII value. You can find all the ASCII values here '1' maps to ASCII value of 49. thus '1' + '1' becomes 49 + 49 which is an integer 98. If you cast