🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: passing parameters to methods to get a value back (by reference in C++) and one other question

#19697
From: Eric Nagler
Date: Fri, 02 Jan 1998 00:00
30 lines
1340 bytes
You can't do that in Java. Integer objects are immutable. 

Integer modify(Integer data)
{
   return new Integer(++data.intValue()):
}
// ...
Integer answer = modify(new Integer(1));
// answer now contains a 2


On Tue, 30 Dec 1997 21:24:38 GMT, ait@concentric.net (Jeff Kish)
wrote:

>Sorry for my vagueness...
>In C++ I can do:
>
>routine(int & modifedByRoutine) {modifiedByRoutine = 6;} // pretend 
>\\ this is a method, not a stand alone function
>
>main()
>{
>int someInt = 2;
>  routine(someInt);
>// someInt equals 6 now
>}
>
>Now, how to do this in Java, i.e. make the parameters return something
>"changed" to the calling environment
Technical Details
Message-ID: <34af6bf9.24873645@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34a9282d.69646145@forums.borland.com> <34a9583d.11419067@forums.borland.com> <34aa6612.85491420@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,90bf066ce13115b3
X-Google-Attributes: gidf74b3,public
From: 76711.521@compuserve.com (Eric Nagler)
Subject: Re: passing parameters to methods to get a value back (by reference in C++) and one other question
Date: 1998/01/02
Message-ID: <34af6bf9.24873645@forums.borland.com>
X-Deja-AN: 312241389
Content-Transfer-Encoding: 7bit
References: <34a9282d.69646145@forums.borland.com> <34a9583d.11419067@forums.borland.com> <34aa6612.85491420@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language