Java Reference
In-Depth Information
Differences Between Primitive and Class-Type Parameters
A method cannot change the value of a variable of a primitive type that is an argument to
the method. On the other hand, a method can change the values of the instance variables of
an argument of a class type. This is illustrated in Display 5.16.
Display 5.15
Memory Picture for Display 5.14 (part 1 of 2)
Before anything:
We do not know what memory address
(reference) is stored in the variable
anObject
aParameter
?
. Let's say it is 3078. The exact
number does not matter.
anObject
3078
Someplace else in memory:
3078
Mr. Cellophane
0
is plugged in for
anObject
aParamter.
and
become two names for the same object.
anObject
aParameter
aParameter
3078
anObject
3078
Someplace else in memory:
Mr. Cellophane
3078
0
(continued)
 
 
Search WWH ::




Custom Search