Hi guys,

I found this thread (http://www.daniweb.com/forums/thread19814.html) that gave me guidance on this topic but I wanted to further develop my understanding.

I understand that in Java, everything 'passes by value', even references. That is, a copy of the value is passed to the parameter so the original value is left unchanged.

In the cases of when Java "passes-by-reference" it is still passing by value as its passing the value of a copy of the reference to the object for example: a balloon analogy:

Balloon = object
String connected to the balloon = reference

So when "passing-by-reference", what's happening is that a copy of the reference to the original object is being passed enabling the original value to be modified? In keeping with the balloon analogy, would it be correct to say that the object (the balloon) now has 2 references (strings) attached to it, that is, the original reference and the copied reference being passed?

Thanks.

Edited 6 Years Ago by pac-man: n/a

... would it be correct to say that the object (the balloon) now has 2 references (strings) attached to it, that is, the original reference and the copied reference being passed?

Yes

This question has already been answered. Start a new discussion instead.