DEV Community


Discussion on: Pass by value/reference :EXPLAINED WITH SINGLE GIF (Believe me it's true)

aplich profile image
Arek Plich

Gif can be very confusing by implying that after passing an object as a method argument, you can do whatever you want with it without changing the original object.

As you know, only the reference to the object is copied (finally we have two references) which still points to the same object and any modification to it will be reflected in the source object (on the heap) to which these references point.

The above gif only applies in the context of passing primitives.