Skip to content

Passing an object and changing it anyway

A method receives an object, modifies one of its fields, and the caller sees the change. The same method reassigns the parameter to a new object, and the caller does not see that.

What explains both?