[EMAIL PROTECTED] wrote:
>
> I expected the following to work since Objects are supposedly
> pass-by-reference. Am I doing something wrong here?
>
> I'm just trying to change a Boolean value inside of a method and return
> as pass-by-reference to the caller.
>
> My environment is:
> Blackdow
> I expected the following to work since Objects are supposedly
> pass-by-reference. Am I doing something wrong here?
Yes: in the method you are chaning the reference, not the obejct.
E.g.:
Boolean a = Boolean.TRUE;
Boolean b = a;
b = Boolean.FALSE;
at this point, a is still equal to Boolean.
Your BooleanTest2 is assigning a new reference (i.e., a reference to a
different object) to the local variable "b". It's not changing the
object whose reference was passed in from main().
If you wanted to change the object passed in from main, you would need
to operate on *that* object... somethi
Hi Paul,
"objects are passed by reference" is only half of the truth. In fact,
this is implemented by passing the reference to the object (in C you
would call it a pointer) by value. Your parameter Boolean b in
changeBoolean() is this reference. By assigning to the reference, this
reference will
Paul Grepps wrote:
>
> I expected the following to work since Objects are supposedly
> pass-by-reference. Am I doing something wrong here?
Yes :-)
> I'm just trying to change a Boolean value inside of a method and
> return as pass-by-reference to the caller.
in changeBoolean() you are not ch
I expected the following to work since Objects are supposedly pass-by-reference.
Am I doing something wrong here?
I'm just trying to change a Boolean value inside of a method and return
as pass-by-reference to the caller.
My environment is:
Blackdown JDK1.2 pre2, RedHat 6.1, glibc 2.1.2
The outp