All > Technology > Programming > Java
A semantics of passing an argument to a method in which a copy of the actual argument value is taken and placed in a separate memory location, represented by the corresponding formal argument. As a result, assignment to a formal argument within a method can have no effect on the value stored in the actual argument. This principle is often misunderstood in Java. It does not mean that an object referred to by an actual argument cannot be modified via the formal argument. Consider the following example of sorting the array referred to by the variable
numbers
Arrays.sort(numbers);
Thesort
method will change the order of the values stored in the object referred to bynumbers
. However, it is impossible for thesort
method to change which arraynumbers
refers to - a sorted copy, for instance. Some languages provide an argument passing semantics known as call-by-reference, in which an actual argument's value may be changed. Java does not provide this, however.- Browse Related Terms: actual argument, actual parameter, actual parameter list, anonymous array, anonymous object, argument, call-by-value, command-line argument, constructor, copy constructor, formal argument, formal parameter, formal parameter list, instanceof, method, method header, method overriding, parameter
Also listed in:
- All > Technology > Programming > Perl