- 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); //这里被追加了 输出AB
- y=x; //为什么这里没有改变 输出还是B
- }
- }
- 运行结果是 AB,B
复制代码 |
|