Article View: borland.public.jbuilder.java.language
Article #7258Re: can i change a int type Not Integer type argument in a function ?
From: webseal
Date: Thu, 28 Jun 2001 12:24
Date: Thu, 28 Jun 2001 12:24
39 lines
1660 bytes
1660 bytes
I am not sure, if I understood your question right.
In my opinion your code is okay but it will not return the new value
11 in i.
Instead you should write
public func1(){
int i = 10;
i = func2( i ); //set value of function to i
System.out.println( i ) ===> 11
}
public int func2(int arg){ // 'int' is important for return value
arg = arg + 1;
return arg; //pushes the value back
}
On Thu, 28 Jun 2001 19:26:23 +0800, "wallance" <wallance@sh.ctil.com>
wrote:
>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:
<3b3b2108.5175232@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnewsReferences:
<3b3b1371_2@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 05:29:39 PST From: webseal@web.de (webseal) Newsgroups: borland.public.jbuilder.java.language Subject: Re: can i change a int type Not Integer type argument in a function ? Date: Thu, 28 Jun 2001 12:24:20 GMT Message-ID: <3b3b2108.5175232@newsgroups.borland.com> References: <3b3b1371_2@dnews> X-Newsreader: Forte Free Agent 1.21/32.243 NNTP-Posting-Host: 62.224.165.163 X-Trace: dnews 993731055 62.224.165.163 (28 Jun 2001 05:24:15 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-03!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews