Meaning of + symbol with Strings in Java println statement

后端 未结 7 911
孤独总比滥情好
孤独总比滥情好 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:14

    The + sign in the context of strings is the concatenation operator. It joins two strings together.

    E.g.

    String str = "hello" + "world";
    

    would result in a String object called str, with a value of "helloworld".

提交回复
热议问题