call by value
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);The
sort method will change the order of the values stored in the object referred to by numbers. However, it is impossible for the sort method to change which array numbers 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.Perl
An "argument"-passing mechanism in which the "formal arguments" refer to a copy of the "actual arguments", and the "subroutine" cannot change the actual arguments by changing the formal arguments. See also "call by reference".