In C #, the values are changed when called in the secondary function, and changes are also made in the main function
The REF keyword causes the argument to be passed by reference. The effect is that when control passes back to the calling method, any changes made to the parameter in the method are reflected in the variable. To use the ref parameter, both the method definition and the calling method must explicitly use the REF keyword
The Out keyword causes the arguments to be passed by reference. This is similar to the REF keyword, except that ref requires that the variable be initialized before it is passed. To use the out parameter, both the method definition and the calling method must explicitly use the Out keyword.
Java inside unlike C #, Java only Object type parameter is the address, Java base type variables to do parameters, all just pass the value.
The solution is to use the Java class as the parameter type of the function.
The following is an example of what I wrote:
FileName: Byrefvariable.java
--------------------------------------public
class byrefvariable{public
static void Main (String args[]) {
obj test=new obj ();
System.out.println ("The value of the Test.var that is not passed to the Changeit method by the test as an argument =" +test.var);
Changeit (test);//Sit arguments passed to a function!
System.out.println ("test as argument passed to Changeit after" +test.var);
}
public static void Changeit (obj a) {
a.var=12580
}
}
Class obj//I define a class here.
The above is a small series for everyone to implement in the Java C # syntax in the reference to pass the parameters of the method of the whole content, hope to help everyone, a lot of support cloud Habitat Community ~