Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 6
    thanks you alot, for explaining in details. Commented Oct 25, 2011 at 20:03
  • 3
    Now i got what "reference to obj as a value" or "sending copy of reference" means :) Commented Apr 16, 2015 at 16:44
  • 1
    The diagrams really helped make these concepts clear! Thank you! Commented Apr 3, 2016 at 21:10
  • 3
    This explanation is very clear, but I'm still a bit confused. In the step 3, "a" is pointing to an object whose attribute is f. To me, "a" seems to be pointing the reference of the object which "f" is pointing too. If objects are passed by values, both "a" and "f" should have their own objects. However, they are actually sharing the same objects (i.e. they are pointing to the reference of the same object). Commented Sep 16, 2017 at 7:22
  • 3
    @Hiroki Objects are not passed by value. It is the pointer to the object that is passed by value. Variables in Java cannot contain objects, they always contain a pointer to the object. And therefore, objects cannot be passed to methods, it is always the pointer to the object that is passed by value to the method. Commented Feb 29, 2020 at 17:35