public class Test {
    public static void main(String[] args) {
        String s1 = "Hello";
        String s2 = "word";
        String s3 = "!";
        //StringBuffer下面的append方法拼接字符串 ————拼接字符串方法1
        StringBuffer buffer = new StringBuffer();
        StringBuffer append = buffer.append(s1).append(" ").append(s2).append(s3);
        String s4 = new String(append);
        //String 下面的format方法拼接字符串————拼接字符串方法2
        String s = String.format("%s %s%s", s1, s2, s3);
        //拼接字符串方法3
        String s5=s1+" "+s2+s3;
        
        System.out.println(s4);
        System.out.println(s);
        System.out.println(s5);
    }
}s


/*

输出结果:


方法一:Hello word!
方法二:Hello word!
方法三:Hello word!
*/