Information Technology Reference
In-Depth Information
Figure 5-9 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.
￿
￿
At the beginning of the method, the names of the formal parameters are 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. The names A1 and A2 are out of scope and can-
not be accessed from inside the method.
Inside the method, the code creates an object of type MyClass and assigns it to f1 . It then
assigns a value to f1 's field and also assigns a value to f2 . The assignment to f1 and f2 are
both required, since they are output parameters.
￿
￿
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-9. Output parameters
Search WWH ::




Custom Search