Java The object is never passed in the application, but only the object is applied, so it is passed by object reference.
(1) When an int is passed as a parameter, the argument is worth modifying without affecting the arguments.
(2) When stringbuffer as a parameter, the modification of the content of the formal parameter object affects the actual parameter.
(3) A value pass simply passes a copy of the value, and the value of the argument is not affected by the change to the parameter.
(4) A reference is passed, because the address of the parameter is also passed as a value, so the address of the argument cannot be changed, only the value of the object to which the actual parameter address points is changed.
(5) The string object is passed, because the value of the string object cannot be modified, so when the string object is a parameter, the modification of the formal parameter does not affect the address of the argument, nor does it change the value of the object to which the argument address points. As an object reference, if the object contains a string-type property, the property's set method can be used to set the property, but the address value is changed.
(6) When a method is called, the modification of the property value of the object referred to by the parameter reference is visible to the argument. However, modifications to the reference value itself are not visible to the arguments.
String string1 = "123";
string1 = string1 + "345";
The definition of a string s is actually a pointer to a string object, string1 = String1 + "345"; A new string object is created to hold the new class capacity, and the original is still in memory, but s no longer points to it.
(String1 and "345" are string objects, strings are concatenated, which inevitably opens up space to store new string objects)
Value passing and reference passing in the Java language