There are many examples on the internet, I am lazy, do not write an example, write their feelings.
In Java, it is a value pass or a reference pass, which I think is not very important, but what is important is the understanding of delivery.
The parameters in the method are divided into two types
- Basic data types
- Reference data types (classes, interfaces, arrays)
When a parameter is a base data type, the JVM copies the argument value, which is the value of the variable, to the parameter, and any operation on the formal parameter in the method does not affect the actual parameter value;
When a parameter is a reference data type, the JVM copies the argument object, the address value, to the parameter, and the parameters and arguments to the memory in the same heap, which can change the value in the memory, affect the argument, but if the memory that the parameter points to changes, the action on the parameter in the method does not affect the argument.
can look at (ox _ Ox). NET article http://www.cnblogs.com/SilentCode/p/4858790.html
About value passing or reference passing in Java