🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#19763
From: Jeff Kish
Date: Tue, 30 Dec 1997 00:00
44 lines
1909 bytes
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

Thanks for your patience, 

Jeff Kish
ait@concentric.net

On Tue, 30 Dec 1997 20:26:44 GMT, 76711.521@compuserve.com (Eric
Nagler) wrote:

>On Tue, 30 Dec 1997 17:00:42 GMT, ait@concentric.net (Jeff Kish)
>wrote:
>
>>Can I do it? I am having a problem returning an integer value via a
>>public methods parameter. Can someone help me here? Is there such a
>>thing as by reference in Java? Do I need to force it to a string?
>
>Your question is vague. What are you trying to do? Return an 'int' by
>reference? It can't be done. And of course there are references in
>Java (as opposed to pointers).
>
>>How do assignments work if you don't define a copy constructor?
>
>In C++ there is no connection between an assignment and the invocation
>of a copy constructor. When you "assign" in Java, you are just making
>two references refer to the same heap-based object. Same principle for
>initialization.
>
>
Technical Details
Message-ID: <34aa6612.85491420@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34a9282d.69646145@forums.borland.com> <34a9583d.11419067@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: ait@concentric.net (Jeff Kish)
Subject: Re: passing parameters to methods to get a value back (by reference in C++) and one other question
Date: 1997/12/30
Message-ID: <34aa6612.85491420@forums.borland.com>
X-Deja-AN: 311430569
Content-Transfer-Encoding: 7bit
References: <34a9282d.69646145@forums.borland.com> <34a9583d.11419067@forums.borland.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: None
Newsgroups: borland.public.jbuilder.java.language