Why can I add characters to strings but not characters to characters?

前端 未结 7 834
陌清茗
陌清茗 2020-12-21 09:18

So I wanted to add a character to a string, and in some cases wanted to double that characters then add it to a string (i.e. add to it itself first). I tried this as shown b

7条回答
  •  情深已故
    2020-12-21 09:52

    When you do char s = 'X'; String string = X + X;

    Why not do this instead? char s = 'X'; String string = s + s;

提交回复
热议问题