How do I concatenate two strings in Java?

前端 未结 23 3384
长情又很酷
长情又很酷 2020-11-22 04:47

I am trying to concatenate strings in Java. Why isn\'t this working?

public class StackOverflowTest {  
    public static void main(String args[]) {
                


        
23条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 05:06

    You can concatenate Strings using the + operator:

    String a="hello ";
    String b="world.";
    System.out.println(a+b);
    

    Output:

    hello world.

    That's it

提交回复
热议问题