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 . Let's say it is 3078. The exact
number does not matter.
aParameter
?
anObject
3078
Someplace else in memory:
Mr. Cellophane
0
3078
anObject is plugged in for aParamter.
anObject and aParameter become two names for the same object.
aParameter
3078
anObject
3078
Someplace else in memory:
3078
Mr. Cellophane
0
 
Search WWH ::




Custom Search