public class Stringtest {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
StringBuffer a = new StringBuffer ("a");
StringBuffer B = new StringBuffer ("B");
Operate (A, b);
System.out.println (a.tostring () + "," + B);
}
static void Operate (StringBuffer x, StringBuffer y) {
TODO auto-generated Method Stub
Y.append (x);
System.out.println ("=============");
System.out.println ("y=:" +y+ "This is the incoming B");
System.out.println ("x=:" +x+ "This is the incoming a");
y = x;
System.out.println (y = x);
System.out.println ("-------------");
System.out.println ("y=:" +y);
System.out.println ("x=:" +x);
System.out.println ("=============");
}
}
Results: A,ba
For example string A=a here the character "a" will open a physical address to store "A" This value , reference A will also open a physical address to hold the character "a" storage location . When you use string b = A to assign a value, the physical address of a is passed to B instead of the address of the character "a". Changing the contents of the B reference at this time does not affect the content of a reference at all. The two temporary variables A and b are discarded after the method ends, which does not alter the object referenced by Y.
Java Fundamentals-value passing and application passing