Quote:Original post by Fred304
I care. If someone states that Java passes objects by reference and I know it is wrong, why shouldn't I correct the person?
I work with lots of beginners, and they all have their troubles with this issue, so I think it's very important to be clear about this.
So explain it completely. It's not a bug, it's a feature.
If your car doesn't fly is that a limitation? Why would you want use a car when you need to fly in the first place?
Java was designed this way. We manage to get the reference inside methods and work with it. If academically this is called "pass by magic" it couldn't matter less for our daily work.
The lack of practical examples doesn't help beginners. What I see is a bunch of C++ developers trying to find pretexts for bashing Java as if this single "detail" was the very meaning of life and all developer's work gravitates around it.
Quote:Original post by Fred304
Quote:
if ALL I NEED is to work with the class inside of the function???????????????????????
How often do you work with classes? Most of the times, you'll be working with (references to) objects.
And what does it have to do with what I said? Are you implying that not following the correct nomenclature will make people's work impossible?
That's something funny. Let's settle this, let's call it "pass by magic" from now on, and let's see if all systems stop working at the same moment.
Quote:Original post by Fred304
A swap function maybe?
BTW it's not about changing the instance (because that's totally possible by sending messages to the instance!), it's about changing the reference. Letting it point to ANOTHER instance.
Whatever you want to call it, but the result will be the same.
Me: I'm going to travel to city X in a blue dodge viper.
You: I'm going there to with a red dodge viper and listening to Korn.
Me: Ok, so I see you there then.
You: No, I am going with a "RED" dodge viper and "LISTENING TO" Korn. I will see you there in my "RED" dodge viper and "LISTENING TO" Korn.
Me: Ok, what's the difference? Won't we be there anyway?
You: No, I am going with a "RED" dodge viper and ... (ad infinitum)
What's your point? Please elucidate how Java works and don't treat that as limitation.
"Oh, my computer is not a spaceship, that's a limitation, I will have to work around it!"