This article is a summary, welcome to discuss!
In Java, the conversion of parameters is high, but it is easy to clearly distinguish. For objects, some are complicated.
First, in Java, a variable of a class is declared. Then, use the class to generate an instance of a class, that is, the instance area of the class in the memory, and finally assigns this variable of this area. Note that the variable is in the pointer to the object.
If it is based on the delivery parameters, it is to change the memory object area referred to in this object variable, that is, to assign a new object to object variables outside the method within the method. However, this is not available in Java. Because Java is incorporated into the object pointer in the object variable, it does not incorporate the address of the address itself into the method; in the method, a new variable is generated to accept the pointer to accept this object. Therefore, in the Java method, the contents of the current object can be changed, but the value of the outer variable is not changed, that is, the object pointing. For transmission values, the analysis of the address is to make less mistakes in the application. Others are secondary.
"This location has pictures, because you can't upload, so delete"
0: Public class demotest {
1: Public String x;
2: Public void setx (string x) {
3: this.x = x;
4:}
5: Public void test (demotest ok) {
6: ok = new demotest (); this.x = "333";
7:}
8: public string getX () {
9: Return this.x;
10:}
11: public static void main (string [] args) {
12: Demotest ob = New demotest ();
13: Demotest OBP = New Demotest ();
14: ob.setx ("111");
15: System.out.println ("ob.x" ob.getx ());
16: OBP.TEST (OB);
17: System.out.Println ("ob.x" ob.getx ());
18: Ob.test (ob);
19: System.out.println ("ob.x" ob.getx ());
20:}
twenty one: }
For the above programs, you must clear the object variables and object entities.
Note that the above method call is a call that may lead to an error, and cannot explain the difference between the pass value and the address.