🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#7260
From: Stefan Bouynov
Date: Thu, 28 Jun 2001 13:57
47 lines
1933 bytes
Your code is just about alright, I suggest the following:

public void func1(){
     int i = 10;
    System.out.println(func2(i))  //===> 11
 }
 public int func2(int arg){
     arg = arg + 1;
 }

You don't have to convert i to an Object, because PrintStream (System.out in
this case) has println(int) method. But if you want to convert int to an
object anyway - you would use Integer class:

Integer objI = new Integer(i);

The reverse convertion looks:

int i = objI.intValue();

There is a "wrapper" object for every primitive type: Byte for byte, Short
for short, Boolean for boolean, etc.

Regards,
Stefan


"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: <3b3b2892_1@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>

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:56:41 PST
From: "Stefan Bouynov" <bouynov@yahoo.com>
Newsgroups: borland.public.jbuilder.java.language
References: <3b3b1371_2@dnews>
Subject: Re: can i change a int type Not Integer type argument in a function ?
Date: Thu, 28 Jun 2001 15:57:50 +0200
Lines: 49
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: 212.56.7.50
Message-ID: <3b3b2892_1@dnews>
X-Trace: dnews 993732754 212.56.7.50 (28 Jun 2001 05:52:34 -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