Meaning of + symbol with Strings in Java println statement

后端 未结 7 909
孤独总比滥情好
孤独总比滥情好 2021-01-16 09:57

I\'m new to Java. What does the below mean?

(addition) + sign in println

System.out.println ("Count is: " + i);

相关标签:
7条回答
  • 2021-01-16 10:19

    When one of the operands to + is a String, the java compiler converts the other argument to a string too, and concatenates them into a new string.

    If i is 1 the result is "Count is: " + "1" which is "Count is: 1"

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