| CSC300: Assignment and Parameters with Object Types [15/24] | ![]() ![]() ![]() |
Very Important!
Assignment, or passing a reference to an object of some type to a method with an object type parameter results in copying the address of the object to a new place in memory.
This includes boxed types, arrays, and any other object for which a class is defined. Modifying the data in the object (if the object is mutable) affects what the calling code "sees".
|
Note: The variable y in the main program is simply an alias for the object also referenced by the variable x.
The variable y in the function f is pointing at the same object (although we wouldn't call it an alias here)!