View Single Post
Old 05-05-2004, 08:35 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
So in your code, "c" is nothng but an "object reference". So when you pass it to your ID function, you will pass a COPY OF THE REFERENCE.
Aha, now I see what Java is about .

So you could "alter" the value(s) in "c" but you cannot interchange it with other objects if passed to the same function (like a "b" for example).
You need to use the original references for that.

That's what I understood from that text.

So try your experiment like this:
- Make a swap function.
- Give objects b and c a value in main. (your current customer objects will do just fine).
- pass them to your swap function.
- swap them.
- test in main: fails.
- in swap function: assign new value (name and id) to "c".
- test in main: success, value of c has changed.

Watch it, strings are passed by VALUE. No copies of references are made.
And it is certainly not a reference like in C++.

That's what I understood from that story. But you gotta test it in the swap function I proposed. I don't have Java.
__________________
Valmont is offline   Reply With Quote