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 output of the following program is:
Boolean before: false
changeBoolean(): false
changeBoolean(): true
Boolean after: false

I expected the Boolean after: to be true.

----------------------------------------------------------------------
public class BooleanTest2 {
    public void changeBoolean(Boolean b) {

        System.out.println("changeBoolean(): " + b.booleanValue());
        b = Boolean.TRUE;
        System.out.println("changeBoolean(): " + b.booleanValue());
    }

    public static void main(String args[])
    {
        BooleanTest2 bt = new BooleanTest2();
        Boolean bool = new Boolean(false);

        System.out.println("Boolean before: " + bool.booleanValue());
        bt.changeBoolean(bool);
        System.out.println("Boolean after: " + bool.booleanValue());
    }
}

begin:vcard 
n:Grepps;Paul
tel;home:(703) 327-0768
x-mozilla-html:TRUE
org:Lightningcast Inc.
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
title:Principal Engineer
x-mozilla-cpt:;0
fn:Paul Grepps
end:vcard

Reply via email to