🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14483

Re: Big Question !!!

#14483
From: Kobus du Toit
Date: Fri, 03 Sep 1999 00:00
47 lines
1656 bytes
I think it is like this.  When you cal setToNull you also create a
variable called myVar.  You set myVar to null and not myXXX.  Also if you
set something to null I think it will be garbage collected and you lose
the whole object, if that is what you want.  That is where the global and
local variables come in.

What you can do is declare a private var called XXX FmyXXX and then use
that.

Kobus



Gemplus Software wrote:

> Hello,
>
> I know that  passing  an object to a function is by reference.
>
> So Why if I do that the object passesd is not modified. Illustration:
>
> Class XXX {
>
>    int myInt;
>
>     public XXX() {
>         myInt = 2;
>     }
>
>     public void setToNull ( XXX myVar) {
>       myVar = null;
>     }
>
>    public String toString() {
>      return "myInt = " + myInt;
>    }
>
>    public static void main(String[] args) {
>    XXX myXXX= new XXX();
>
>    myXXX.setToNull(myXXX);
>
>    System.out.println("myXXX is " + myXXX.toString());
>    }
> }
>
> displays myXXX is myInt = 2. Why ????
Technical Details
Message-ID: <37CF8080.D6E719B6@iname.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37CF7931.706BF049@gemplus.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,5929964ef2095e5a
X-Google-Attributes: gidf74b3,public
From: Kobus du Toit <battlezone@iname.com>
Subject: Re: Big Question !!!
Date: 1999/09/03
Message-ID: <37CF8080.D6E719B6@iname.com>
X-Deja-AN: 520527257
Content-Transfer-Encoding: 7bit
References: <37CF7931.706BF049@gemplus.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Reply-To: battlezone@iname.com
Newsgroups: borland.public.jbuilder.java.language