> > 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.

But String objects are immutable: no method can change it.

So if myMethod changed s, then I would be the Pope, and the sun would
rise from the west, and the string that gets printed would depend on
what myMethod did to s.  You are perfectly vacuously right.

And I totally agree with Peter Schuller's point.

"Peter Schuller" <[EMAIL PROTECTED]> writes:

> 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.

[...]


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to