[quote user="growse"]
I'm not a java dev. I'm an amateur c# dev. I don't have a CS degree. let me see if I get this straight.
In c#, you can either do foo(obj) or foo(ref obj). In the former case, whatever 'foo' does to obj will only affect whatever's going on local to foo. In other words, a copy of obj is made in memory, and the reference is sent off to foo. Maybe stored as the value of a variable, I don't know. I would guess that a pass-by-reference system would pass the reference of the new object to foo, and pass-by-value would store the reference in a variable, and then pass the value of that variable to foo. In the latter case, the reference to obj is taken, and that's sent to foo. Because foo has the reference to the original object obj, it can play around with it and affect that actual object.
So, with java, because it's always pass by value, but objects are never passed, is it always the case that when I do foo(obj) that obj is copied, the new reference to that object stored in a variable, and the value of that variable passed to foo?
[/quote]
Structures, By Value
The function you called gets a copy of the data. No changes ever make it back to you.
Structures, By Reference
The function you called get a reference to the data. Any changes it makes are returned to you.
Classes, By Value
The function you called gets a copy of the pointer to the object. Any changes it makes to the object are returned to you.
Classes, By Reference.
The function you called gets a reference to the pointer to the object. Any changes it makes to the object are returned to you. In addition, it can change your pointer to point to an entirely difference object.
Java only has "Classes by Value". It doesn't have structures, nor does it have by reference passing.