代码如下:
public class Demo {
public static void main(String[] args) {
String str = "abc";
String str1 = str + "de";
System.out.println(str);
System.out.println(str1);
System.out.println();
StringBuffer sf = new StringBuffer("abc");
StringBuffer sf1 = sf.append("de");
System.out.println(sf);
System.out.println(sf1);
}
}
输出结果:
abc
abcde
abcde
abcde