Re: pass by reference



Lew <lew@xxxxxxxxxxxxx> wrote:
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.

This indication of lingual hairsplitting perhaps explains, why I got
somewhat less than 100% for my SCJP (but still by far enough to pass).
Can't say for sure, since one is never told, which of the questions
were really answered wrongly.

Just as well one could say that nothing at all is passed (since methods
don't have arms or hands to pass things around), but only written to some
physical memory-location where it is then accessible to the called method...
and then we go on, that the jvm doesn't really "call" the method, because
the method doesn't have ears to hear any calling...(btw., "invoke" also has
an etymology that boils down to some form of akoustic communication.)
Really, this makes me sick.

.



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)