2.13 Passing and returning objects
Introduction
Java passes all arguments by value — but for objects, the "value" being copied is the reference, not the object's data. This means a method can modify the fields of an object passed to it (both the caller and the method see the same object), but reassigning the parameter itself inside the method does not affect the caller's reference. Methods can also return objects, handing a reference back to the caller.
Key Concepts
Java Syntax
Code Examples
`mutate` changes a field on the shared object, so the caller sees the update. `reassign` only points the local `s` parameter at a new object — `ama` in `main` is untouched.