引用地址的变化
1 public static void main(String[] args) { 2 StringBuffer a=new StringBuffer("A"); 3 StringBuffer b=new StringBuffer("B"); 4 operator(a,b); // 1 5 System.out.println(a+","+b); // 3 6 } 7 public static void operator(StringBuffer x,StringBuffer y){ 8 x.append(y); 9 y=x; //当 y = x时,你是改变了 y 的引用指向 2 10 } 11 } 12 13 14 //1. a = A b = B a:内存1 b:内存2 15 //2. a = AB b = AB a:内存1 b:内存1 16 //3. a = AB b = B a:内存1 b:内存2