Slide 5
Slide 5 text
Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 5
Objects as Parameters
• Since a1 is a primitive data, any change that was made
to f1 in the method changeValues does not affects a1
• The object a2 was assigned to the value “222” and
when a2 was passed to changeValues method, a2 and
f2 became aliases so the change made to f2 will be
seen in a2 in the main method.
• The object a3 was assigned to the value “333” and
when a3 was passed to changeValues method, a3 and
f3 became aliases.
However when f3 was re-instantiated with the reserved
word new, f3 is given a different address from the one a3
has, thus any change made to f3 after that point will not
affect a3 in the main method.