请问,该题的输出是什么?是关于值传递的!
public class Test{
public static void main(String[] args){
StringBuffer a=new StringBuffer("A");
StringBuffer b=new StringBuffer("B");
operate(a,b);
System.out.println(a+","+b);
}
public static void operate(StringBuffer x, StringBuffer y){
x.append(y);
y=x;
}
}
what is the output?
答案:AB,B
我不理解,为什么y=x这一句没有改变b?请大侠指点一下!!多谢.