Re: pass by reference



Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote:
With objects, Java still does a). The parameter is a variable that
references the object. It's not the object itself. And a copy of that
reference the variable holds is passed. If Java did support
pass-by-reference, and you passed an object reference "by reference", then
reassigning the reference would not change the original object, but rather
would change the variable that was pointing to (referencing) that object.

I dare the bold assumption, that all partitioners in this discussion do
know how java works.

We're only discussing human language here, not Java's features.

a) Does anyone disagree, that "pass an Object by reference" and
"pass the reference to an Object by value" refer to the same
technical feature?

b) Does anyone disagree that "pass a reference by reference" is an
entirely different feature that is not directly supported by
java, but can be effectively mimicked with arrays and/or Holder-
classes?

Would anyone care to point out any difference of the two concepts in
"a)" without mixing it up with the concept in "b)" ?

In C#, you can additionally pass parameters by reference, including references.

This is also "pass ... by reference", but with C#'s meaning of references,
whereas Java's "pass Objects by reference" is based on java's "references".
Therefore "pass by reference" means something different depending on
the language context.

If you insist on saying that passing a reference to an object is "passing
by reference", then what does it mean to pass a reference by reference, as
you can do in C# (and C++ for that matter)?

exactly that: "pass a reference by reference" :-)

.



Relevant Pages

  • Re: How java passes object references?
    ... Which everybody knows, it doesn't in Java. ... The reason I think this is a useful clarification is that when you got to the part about how passing by reference might work, it seems you went off track at least partly because you didn't understand the nature of the above. ... is a pointer pointing at the memory block. ... Assignments to local variables, or even to class members, do not allocate memory. ...
    (comp.lang.java.programmer)
  • Re: The Java no pointer big fat lie!
    ... > reference types, it wouldn't be a good comparison. ... and what you can't - and there is a big difference in Java to C and C++. ... You cannot change it in the language itself, ... Thus I would distinguish pointers from ...
    (comp.lang.java.programmer)
  • Re: call by reference
    ... We started learning Java about one month ago, and they just don't believe me when i try to explain that there is a confusion when passing reference types as an argumetn to a function. ... The actual parameter must be an L-value. ...
    (comp.lang.java.programmer)
  • Re: programming concepts > specific languages
    ... >actually changes the target of the reference passed to 'function2'. ... Java from a source that was not precise about terminology. ... if I have a class MyObject and write ... I thought primitive types in particular behave in the ...
    (comp.programming)
  • Re: no pointer in Java => my problem
    ... Does Java pass objects by reference or by value? ... f could also modify the StringBuffer by appending " World" for instance. ...
    (comp.lang.java.programmer)