How do I concatenate two strings in Java?

前端 未结 23 3394
长情又很酷
长情又很酷 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:17

    You can concatenate Strings using the + operator:

    System.out.println("Your number is " + theNumber + "!");
    

    theNumber is implicitly converted to the String "42".

提交回复
热议问题