🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Simple question for gurus ;)

#8398
From: Dave Bird
Date: Wed, 21 Mar 2001 22:12
62 lines
3020 bytes
In article <1OO$GeKtzrt6EwuU@xemu.demon.co.uk>, Dave Bird writes
>In article <Z_tt6.19$xH3.1481@psinet-eu-nl>, John Good writes
>>
>>I've got a strange problem with Java, it's probably a feature, but please
>>point me to solving this.
>
>
> Wow; even in C++ what you have written would not work without
> declaring   public void test( int &param ){.........
> That little "&" makes a difference :-> !
>
> In Java variables EXIST as one-word values for a simple numerical
> type and EXIST as one-word locations for class or array objects.
> If you pass an integer, you pass the numerical value.
> If you pass a class-object, you pas the location of the object
> as allocated in the calling routine.  
>
> This will work:

 Sorry, I had a slight brain-fart. This will work, but it is easier
 to use an ARRAY abject, e.g. an array of one interger(s). Then the
 location of the array will be passed to the subroutine, and you
 can change its first element.
>
> public class WrapsInt{
>    public   int x;
>    WrapsInt(){      x=0; };
>    WrapsInt(int h){ x=h; }
> }
> public class SomeWork{
>    ...............
>    public void doFirst(){
>       WrapsInt     exampleParam = new WrapsInt(0);
>       doInside(    exampleParam );
>       int result = exampleParam.x; ........
>    };
>    public void doInside( WrapsInt theParam ){
>       theParam.x = 5;
>       .......
>    };
>    ........
> }
>
> 'result' will be five, not zero.
>
> It's not really a lot of work because usually, when you want to
> change (some fields of) what you passed as parameter, what you
> passed will be a class object anyway; not a simple numerical type. 
>
>
>
> [As best I remember class "Integer" doesn't do what you want,
> it has a single int field which has  **constant** value].
>
>
>

-- 
   ^-^-^-@@-^-;-^   http://www.xemu.demon.co.uk/
        (..)__u     news:alt.smoking.mooses

       happy as a clam at high tide -. <_" .-._.-.
Technical Details
Message-ID: <wFQOkxAadSu6EwmS@xemu.demon.co.uk>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!newshub2.home.com!news.home.com!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!dave
References: <Z_tt6.19$xH3.1481@psinet-eu-nl> <1OO$GeKtzrt6EwuU@xemu.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,a90669a07786d662
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-21 19:22:09 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!news-xfer.nuri.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!newshub2.home.com!news.home.com!dispose.news.demon.net!news.demon.co.uk!demon!xemu.demon.co.uk!dave
From: Dave Bird <dave@xemu.demon.co.uk>
Newsgroups: borland.public.jbuilder.java.language
Subject: Re: Simple question for gurus ;)
Date: Wed, 21 Mar 2001 22:12:42 +0000
Organization: none
Message-ID: <wFQOkxAadSu6EwmS@xemu.demon.co.uk>
References: <Z_tt6.19$xH3.1481@psinet-eu-nl>
 <1OO$GeKtzrt6EwuU@xemu.demon.co.uk>
NNTP-Posting-Host: xemu.demon.co.uk
X-NNTP-Posting-Host: xemu.demon.co.uk:158.152.196.209
X-Trace: news.demon.co.uk 985231076 nnrp-07:29208 NO-IDENT xemu.demon.co.uk:158.152.196.209
X-Complaints-To: abuse@demon.net
MIME-Version: 1.0
X-Newsreader: Turnpike Integrated Version 5.00 U <dQumtnY$x4rJ2u5tL5fS$n2vuP>
Lines: 63