Information Technology Reference
In-Depth Information
Figure 5-8 illustrates the following about the values of the actual and formal parameters at
various stages in the execution of the method:
Before the method call, variables A1 and A2 , which will be used as the actual parameters,
are already on the stack.
￿
￿
By the beginning of the method, the names of the formal parameters have been set as
aliases for the actual parameters. Variables A1 and f1 refer to the same memory location,
and A2 and f2 refer to the same memory location.
At the end of the method, both f2 and the field of the object of f1 have been incremented
by 5.
￿
￿
After method execution, the names of the formal parameters are out of scope, but the
values of both A1 , the reference type, and A2 , the value type, have been changed by the
activity in the method.
Figure 5-8. Reference parameter
Search WWH ::




Custom Search