Let's look at the Java job search book. There is one such thing: in Java, there is no reference transfer, and only value transfer. I don't think so. I checked the information online.
A copy of the reference is actually copied during the transfer of the reference.
A A = new ();
Test ()
Equivalent
(A B =;
Test (B)
)
If the data type is basic, modifying this value does not affect the variable passed in as a parameter, Because you modify the local variable of the method and it is a copy.
If an object is referenced, it is also the same as a copy, but the copy and the reference passed as a parameter point to the same object in the memory, so you can also operate on that object through this copy. However, if you modify the reference itself, such as directing it to another object in the memory, the reference originally passed as a parameter will not be affected.
I think it's okay to understand this. It doesn't matter whether the value is transferred or referenced, but the value transfer is more suitable. This value can be a reference or a basic data type.
--------- Reference others' words
It is true that all calls are passed by value, because the call stack principle limits that we can only press various values into the stack, and when the method returns, instead of processing the values in the stack, simply adjusting the stack top pointer will discard the values originally pushed into the stack. Therefore, all the parameters passed to the method body for the pressure stack, the modifications made inside the method are invisible to the outside world. In view of this situation, in order to bring the parameter modification of the function to the function, different languages have done different processing, and pointers can be passed in C/C ++, by default, Java transmits object references. If the landlord has to call the method to press the stack address as a value, it is actually not impossible, but I think this is a little far-fetched.
--------- Reference others' words
Agree with the two comments! Thank you.