比如说 String id="h" String id1="ello" 我想将id和id1加起来 得到hello 怎么弄呢??

解决方案 »

  1.   

    用String的concat()方法可以连接字符串,比如:id.concat(id1);但是这个方法没有副作用,也就是不会改变原字符串的值.
      

  2.   

    也可以用StringBuilder。
    调用StringBuider.append("String");
      

  3.   

    String s1="h";
    String s2="ello";
    System.out.println("s1+s2="+s1+s2); 
    System.out.println("s1+s2="+s1.concat(s2)); 
    =》
    s1+s2=hello
    s1+s2=hello
      

  4.   

    最笨的方法   StringBuilder   这两个字符串往这容器append  如何toString  从性能上就忘记了