Re: pass by reference



Chase Preuninger wrote:
All objects are "passed by reference" and all primitive types have
their value copied.

As others have stated and illustrated in this thread, that is not actually accurate. That's why those quote marks, presumably.

In the sense that C++ programmers use "reference", Java objects are passed by value, and the official word in Java is that references are passed by value just as primitives are.

In any event, reassigning the formal parameter within a method does not change the reference passed from the caller's point of view.

Stefan Ram provided good examples of idioms to handle the OP's need.

--
Lew
.



Relevant Pages

  • Re: JNI troubles (newbie)
    ... If Java objects have some ... > reference counts correct. ... I would suggest you build a "Java Wrapper" around the native resource, ... be trying for bigger computers, but for more systems of computers. ...
    (comp.lang.java.programmer)
  • Re: compare numbers and mark duplicates
    ... reference in the countif equation? ... if you are referencing a cell do not use the quote marks. ...
    (microsoft.public.excel.misc)
  • Re: Counting string objects question
    ... > I want to confirm if my interpretation about java objects are correct ... > with reference to below examples:) ... so two identical String literals create just one String ... concat() method is forgotten and becomes ...
    (comp.lang.java.help)
  • Counting string objects question
    ... I want to confirm if my interpretation about java objects are correct ... with reference to below examples:) ...
    (comp.lang.java.help)