java parameter passing address problem

When a java object is passed, changing the reference of the formal parameter object will not affect the object value of the actual parameter.

 

code show as below



 When printing the name value in the basic method, since the address of a has already pointed to a2 at this time, the abc value is printed, but the main method a1 has not changed, so when the main method prints the name, the printed value is a1 The value assigned to the method passed as a parameter

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326885426&siteId=291194637