For:
is a value pass. Method calls in the Java language only support value passing of parameters. When an object instance is passed as a parameter to a method, the value of the parameter is a reference to the object. The properties of an object can be changed during the call, but changes to the object reference do not affect the caller. In C + + and C #, you can change the value of an incoming parameter by passing a reference or transmitting a parameter. You can write code like the following in C #, but you can't do it in Java.
Using System;
Namespace CS01 {
Class Program {
public static void swap (ref int x, ref int y) {
int temp = x;
x = y;
y = temp;
}
public static void Main (string[] args) {
int a = 5, B = 10;
Swap (ref a, ref B);
A = ten, B = 5;
Console.WriteLine ("A = {0}, B = {1}", A, b);
}
}
}
Description: There is no reference in Java is very inconvenient, this point in Java 8 is still not improved, it is so in Java code is written in a large number of wrapper class (will need to be modified by the method call to the reference in a wrapper class, Then passing the wrapper object into the method will only make the code bloated, especially for developers who are transitioning from C and C + + to Java programmers.
This method can change the properties of this object and return the changed results, so is this a value pass or a reference pass?