Java, the method passes parameters, and if the parameter is a basic type, it is passed by value, so can it be passed by reference?
void func1() {
int a = 1;
func2(a);
System.out.println(a); // 1
}
void func2(int a) {
a = 3;
}
for example: the above code calls func2 in func1, hoping that the value of a can be changed to 3. Can it be implemented in java?
does not go through the return way.
function is similar to the following CPP implementation:
void func1() {
int a = 1;
func2(a);
cout << a ; // 3
}
void func2(int & a) {
a = 3;
}