posted 19 years ago
Your problem in understanding may be because Java is so simple: people look for complexity and then are confused when they don't find it. Java uses pass-by-value. End of story. The implication of this is:
1. When primitive values, like int values, are passed, a copy of the value is passed. Attemting to alter the copy doesn't alter the original variable:
2. When object references are passed, a copy of the reference is passed. Attempting to alter the local object variable by assigning to it changes the value of the local variable, but not the original reference variable. On the other hand, the underlying object (if the reference is non-null) is not copied, and the original reference and the method parameter start off refering to this same object
C++, because of parameter types like X& is more complicated. Look there for call-by-reference semantics!
There is no emoticon for what I am feeling!