Http://www.bccn.net/Article/kfyy/java/jszl/200601/3069.html
My personal understanding is as follows:
1. For some basic types, it is to pass the value, "Class Object", and to pass the reference;
2. Pass the referenced parameter, public void change (stringbuffer SB ){
// Scenario 1:
SB. append ("I changed ");
// Scenario 2:
SB = new stringbuffer ("I am a new declared space ");
SB. append ("I changed ");
}
Public static void main (string [] ARGs ){
Test. testchange ();
Stringbuffer B = new stringbuffer ("My original status ");
System. Out. println ("Before change" + B );
Test. Change (B );
System. Out. println ("changed:" + B );
}
Running result:
My original status before change
After the change: My original status changed
B In change (B) is actually a reference pointing to B. in Case 1, the reference is the same as B, so it is changed,
Case 2: The reference is changed, and B is no longer the same reference, so how to change Sb has nothing to do with it.