How do I concatenate two strings in Java?

前端 未结 23 3524
长情又很酷
长情又很酷 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 04:59

    import com.google.common.base.Joiner;
    
    String delimiter = "";
    Joiner.on(delimiter).join(Lists.newArrayList("Your number is ", 47, "!"));
    

    This may be overkill to answer the op's question, but it is good to know about for more complex join operations. This stackoverflow question ranks highly in general google searches in this area, so good to know.

提交回复
热议问题