一、形式参数问题
String作为参数传递
StringBuffer作为参数传递
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200208143531225.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1Rpbmcxa2luZw==,size_16,color_FFFFFF,t_70)
public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1="hello";
String s2="world";
System.out.println(s1+"---"+s2);//hello---world
change(s1,s2);
System.out.println(s1+"---"+s2);//hello---world
StringBuffer s3=new StringBuffer("hello");
StringBuffer s4=new StringBuffer("world");
System.out.println(s3+"---"+s4);//hello---world
change(s3,s4);
System.out.println(s3+"---"+s4);//hello---worldworld
}
private static void change(StringBuffer s3, StringBuffer s4) {
// TODO Auto-generated method stub
s3=s4;
s4.append(s3);
}
public static void change(String s1, String s2) {
// TODO Auto-generated method stub
s1=s2;
s2=s1+s2;
}
}