when an object is passed as a parameter to a method, this method can change the properties of the object and return the changed result, is it a value pass or a reference pass?
A: The value is passed.
It can be understood that there is a person (name= "S"), passed as a parameter to a method, in which the person is reset name= "B", then a conclusion
① This person is still the man, it has always been him, but his name has been changed, whether it is the original reference or the reference in the method, the reference is an object, so the value of all references have changed
② If a person is re-assigned to a parameter in the method, then this parameter has no half-penny relationship with the original person (note string sb= "SB" is also a new string)
The Java programming language has only the value pass parameter. When an object instance is passed as a parameter to a method, the value of the parameter is the "reference" of the object to a "Vice". Pointing to the same object, the object's contents can be changed in the called method, but the object's "reference" (not the referenced copy) is never changed.
Java parameters, whether primitive or reference, pass "copy" (another is "pass value"), but a copy is better understood, and the value of the pass is usually relative to the "address".
If the parameter type is the original type, then a copy of the parameter is passed in, that is, the value of the original parameter, which is the same as the value that was previously discussed. If you change the value of a copy in a function, the original value is not changed. If the parameter type is a reference type, then a copy of the reference parameter is passed in, and the copy holds the address of the parameter. If you do not change the address of the copy in the function, but instead change the value in the address, the changes within the function will affect the parameters passed in. If you change the address of a copy in a function, such as new, the copy points to a new address, and the passed in parameter points to the original address, so the value of the parameter is not changed.
In Java, the pass of a function parameter is a value pass or a reference pass