> If Java were pass-by-reference, then in this code fragment:
> String s = "foo";
> myMethod(s);
> System.out.println(s);
>
> In a pass-by-value only language (like Java), you're going to get
> "foo" printed out. In a pass-by-reference language, the string that
> gets printed depends on if myMethod changed s.
Why does everyone miss my point? The *object* is passed by reference. The
*reference* is passed by value. You are passing a reference to a method. A
reference to an object. I think we all agree on that (obviously, if
you pass an object to a method it does not get cloned by the JVM - such
behavior would be crazy).
I am just arguing that the answer to a qustion
"Are parameters in Java passed by reference?" is "Yes, in case of objects,
but not primitives." Because what the person is asking is whether an
*object* is passed by reference. If the person already knows that you are
passing a reference, then why is he/she asking? If the person *really*
wanted to know whether the *reference* is passed by value, it seems likely
that the question would explicitly say just that.
To say "no, they are passed by value" in response to such a question would
likely lead the person asking the question to believe the actual *object* is
being copied.
Again, it's a matter of semantics. I'm not debating what is actually going on.
--
/ Peter Schuller, InfiDyne Technologies HB
PGP userID: 0x5584BD98 or 'Peter Schuller <[EMAIL PROTECTED]>'
Key retrival: Send an E-Mail to [EMAIL PROTECTED]
E-Mail: [EMAIL PROTECTED] Web: http://scode.infidyne.com
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]