🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: can i change a int type Not Integer type argument in a function ?

#7271
From: wallance
Date: Fri, 29 Jun 2001 01:34
42 lines
2092 bytes
my question is can i use "PASS BY Reference" not "pass by value" in java'f
function call?
like in c++ ,you can use    void func(char &arg).

"dnoyeB" <lamont_gilbert @ rigidsoftware.com> wrote in message
news:3b3b7ae2_1@dnews...
> No you can not alter objects within functions.  AS in C and C++, passing a
> primitive OR object into a function always copies.  If its a primitive,
you
> get a copied primitive, if its an object, you get a copied reference.
> Changing the copy does not affect the original.
>
> That way you never have to worry about passing around your references and
> getting them back null.  Again, the only context a value can be set to
null
> is the context in which it was created.
>
>
>
> "wallance" <wallance@sh.ctil.com> wrote in message
news:3b3b1371_2@dnews...
> > hi,
> > i want to change a int type argument in java,what should i do?
> > for example:
> >
> > public func1(){
> >
> > int i = 10;
> > func2(i);
> > System.out.println(i)  ===> 11
> >
> > }
> > public func2(int arg){
> >     arg = arg + 1;
> > }
> >
> > i know in java your can trans a object .then it can modify by reference.
> > but this is int type,not object.what should i do?
> >
> >
>
>
Technical Details
Message-ID: <3b3bda1e_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3b3b1371_2@dnews> <3b3b7ae2_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9b3cb30cd9a02399
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-06-28 18:34:40 PST
From: "wallance" <wallance@sh.ctil.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3b3b1371_2@dnews> <3b3b7ae2_1@dnews>
Subject: Re: can i change a int type Not Integer type argument in a function ?
Date: Fri, 29 Jun 2001 09:34:06 +0800
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 61.170.150.134
Message-ID: <3b3bda1e_2@dnews>
X-Trace: dnews 993778206 61.170.150.134 (28 Jun 2001 18:30:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews