①java中的拼接字符串,常见的的用“+”把字符串进行拼接,如下
String str1 = “hello”;
String str2 = “world”;
System.out.println(str1+str2);
② 运用String类的concat()方法,将一个字符串连接起来
String s1 = “你好”;
String s2 = “”;
String s3 = s1.concat(s2);
System.out.println(s3);
③运用java中的StringBuffer方法中的append的方法
StringBuffer sb = new StringBuffer(“青春无悔”);
int num = 11;
StringBuffer sb1 = sb.append(num);
System.out.println(sb1);
或是直接用 sb.append(“我心永恒”);
System.out.println(sb.toString());