Why does concatenated characters print a number?

前端 未结 7 1716
离开以前
离开以前 2020-12-16 04:44

I have the following class:

   public class Go {
     public static void main(String args[]) {
      System.out.println(\"G\" + \"o\");
      System.out.prin         


        
相关标签:
7条回答
  • 2020-12-16 05:44

    This previous SO question should shed some light on the subject, in your case you basically end up adding their ASCII values (71 for G) + (111 for o) = 182, you can check the values here).

    You will have to use the String.valueOf(char c) to convert that character back to a string.

    0 讨论(0)
提交回复
热议问题