关于方法作用域的问题
public class test4{
//static String x="10";
//static String m="3";
static StringBuffer c=new StringBuffer("C");
static StringBuffer d=new StringBuffer("D");
public static void main(String[] args){
StringBuffer a=new StringBuffer("A");
StringBuffer b=new StringBuffer("B");
test4 test=new test4();
String n="4";
operate(a,b);
test.setvalue(c);
System.out.println(a+"."+b+","+d);
}
static void operate(StringBuffer x,StringBuffer y){
x.append(y);
y=x;
//System.out.println(x+"."+y);
}
public void setvalue(StringBuffer t)
{
d=t;
}
}
为什么结果不是AB.AB,C,而是AB.B,C?