1.问题重述
题目:两个字符串连接程序
2.解析
希望不要小瞧这个题,字符串的拼接有多种方式,不同的方式其效果和作用不同,希望大家可以仔细研究拼接的多种方法。
3.解决问题
代码如下:
// 题目:两个字符串连接程序
public class demo {
public static void main(String[] args) {
String one = "String1";
String two = "String2";
String three = one + two;
System.out.println(three);
StringBuffer sb = new StringBuffer(one);
System.out.println(sb.append(two));
}
}