一、形式参数问题
String作为参数传递
StringBuffer作为参数传递
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;
}
}