public class C {
public static void main(String[] args)
{
int aa=100;
String b="100";
StringBuffer sb = new StringBuffer("100");
C c=new C();
c.A(aa, b, sb);
System.out.println(aa);
System.out.println(b);
System.out.println(sb);
}
public void A(int a,String b,StringBuffer sb){
a=a+1;
b+="1";
sb=sb.append("1");
}
}
输出结果是100
100
1001
不明白为啥会出现这个结果呢?
public static void main(String[] args)
{
int aa=100;
String b="100";
StringBuffer sb = new StringBuffer("100");
C c=new C();
c.A(aa, b, sb);
System.out.println(aa);
System.out.println(b);
System.out.println(sb);
}
public void A(int a,String b,StringBuffer sb){
a=a+1;
b+="1";
sb=sb.append("1");
}
}
输出结果是100
100
1001
不明白为啥会出现这个结果呢?