There is only one way to pass the parameters of a method in Java: value passing
Value passing: When the system starts executing a method, the system initializes the parameter to the parameter of the method, which is not the actual real parametric of the argument variable.
Reference variable: The system replicates the variable, which is the reference address, and does not copy the object itself
eg.
1 classvalue{2 Public intI=15;3 }4 Public classtest{5 Public Static voidMain (String argv[]) {6Test t=NewTest ();7 T.first ();8 }9 Public voidFirst () {Ten intI=5; OneValue v=NewValue (); AV.i=25; - second (V.I); - System.out.println (V.I); the } - Public voidSecond (Value V,inti) { -I=0; -V.i=20; +Value val=NewValue (); -v=Val; +System.out.println (v.i+ "" +i); A } at}
Results: 15 0 20
Note: V in second is not a V in first, so it's clearer to change to TMP.
JAVA Value Delivery