🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Big Question !!!

#14479
From: Gemplus Software
Date: Fri, 03 Sep 1999 00:00
32 lines
1100 bytes
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: <37CF7931.706BF049@gemplus.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

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