Java Reference
In-Depth Information
the method returned, that formal parameter was destroyed and the Num object it
referred to was marked for garbage collection. The only change that is “perma-
nent” is the change made to the state of the second parameter. Figure 7.5 shows
the step-by-step processing of this program.
STEP 1
STEP 2
Before invoking changeValues
tester.changeValues (a1, a2, a3);
a1
a2
a3
a1
a2
a3
111
222
333
111
222
333
f1
f2
f3
f1
f2
f3
111
STEP 3
STEP 4
f1 = 999;
f2.setValue (888);
a1
a2
a3
a1
a2
a3
111
222
333
111
888
333
f1
f2
f3
f1
f2
f3
999
999
STEP 5
STEP 6
f3 = new Num (777);
After returning from changeValues
a1
a2
a3
a1
a2
a3
111
888
333
111
888
333
f1
f2
f3
f1
f2
f3
999
777
= Undefined
FIGURE 7.5 Tracing the parameters in the ParameterTesting program
 
Search WWH ::




Custom Search