For a method (function), the input parameter is passed by value instead of by reference.
It seems that there is no such thing as definition, but the problem is that if the object is passed in, the actual "value" is the address of the object in the memory similar to the pointer. therefore, the method will affect the object value.
Let's look at the example:
Public Class A {
Private Int A;
Public Int Geta () {
ReturnA;
}
Public Void Seta ( Int A) {
This.=A;
}
}
// ========================================================== =====
Public Class Testa {
Public Static Void Main (string [] ARGs) {
A= NewA ();
A. Seta (1);
Changea ();
System. Out. println (A. Geta ());
}
Private Static Void Changea (a aa) {
AA. Seta (10);
}
}
The final result is: 10.
Therefore, if a method imports an object, be sure not to accidentally change the object state.