I have this code:
public class Test {
public static void main (String[] args) {
StringBuffer a = new StringBuffer("A");
StringBuffer b = new StringBuffer("DD");
chng(a,b);
System.out.println(a+","+b);
}
static void chng(StringBuffer x, StringBuffer y) {
y.append(x);
System.out.println("y 1: "+y);
y = x;
System.out.println("y 2: "+y);
System.out.println("x 2: "+x);
}
}
The results are;
y 1: BA
y 2: A
x 2: A
A,BA
I want to know why the last line of the result no equal to A,A?