DISQUS

codesurgeon blog forum: Parameter Passing in Java

  • Scott Stanchfield · 1 year ago
    You might want to take a peek at

    http://javadude.com/articles/passbyvalue.htm

    Hope this helps clear things up a bit...
    -- Scott
  • Burcu Dogan · 7 months ago
    In the increment method, aFoo (the reference alone) is passed by value, so if you access the object through it, it's going to change the value of the existing object on the heap. And reference is going to be destructed since it is local to incrementBar.
    Same doesnt apply to incrementReassignedBar because the local copy is assigned to another local object that is going to be killed soon after method is executed. Great primitive topic most of the devs dont understand :)