Re: pass by reference



"Lew" <lew@xxxxxxxxxxxxx> wrote in message
news:WpSdnSND4qHpiWvanZ2dnUVZ_uTinZ2d@xxxxxxxxxxxxxx
Andreas Leitgeb wrote:
Chase Preuninger <chasepreuninger@xxxxxxxxx> wrote:
All objects are "passed by reference" and all primitive types have
their value copied.

The objects are indeed passed by reference.

When I took a practice certification exam in Java, I was marked wrong for
saying that objects are passed by reference. The fact is that objects are
not passed at all - references are, and they are passed by value.
--
Lew

I think the terminology is bad. I prefer to look at it from a practical
standpoint - can I take the pointer to the Java object (and a pointer it
is), pass it into a method, and make changes to the object pointed to from
within the method, in such a way that those changes are reflected outside
the method? Yes. I may get flunked on a certification exam, but I call that
passing the object by reference.

AHS


.



Relevant Pages

  • Re: pass by reference
    ... Lew wrote: ... The objects are indeed passed by reference. ... When I took a practice certification exam in Java, ...
    (comp.lang.java.programmer)
  • Re: pass by reference
    ... Andreas Leitgeb wrote: ... When I took a practice certification exam in Java, I was marked wrong for saying that objects are passed by reference. ...
    (comp.lang.java.programmer)
  • 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)