🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Returning Object Reference as parameters

#17866
From: John P. McGrath
Date: Mon, 14 Sep 1998 00:00
63 lines
2088 bytes
You could declare a new class containing all three arguments, and pass an 
instance of that class to the method:

   class Arguments {
      Class1 c1;
      Class2 c2;
      Class3 c3;
      Arguments( Class1 c1, Class2 c2, Class3 c3 ) {
         this.c1 = c1;  this.c2 = c2;  this.c3 = c3;
      }
   }

   Caller() {
      Arguments args = new Arguments( c1, c2, c3 );
	Callee( args );
	c1 = args.c1;
	c2 = args.c2;
	c3 = args.c3;
   }

   Callee( Arguments args ) {
      //  Use / Modify args.c1, args.c2, args.c3
   }

-- 
Regards,

John P. McGrath
<mcgrath@enter.net>
<jpm@nscs.fast.net>


Michael Nguyen <michaelmn@home.com> wrote:
> I have a subroutine that takes in several objects of different types.
> This subroutine would assign new objects to these parameters,
> so that the caller can use them.  To do this, I need to declare
> both the variables in the caller and calle's parameters as arrays of
> size one
> as in the example below.  Is there a better way around this
> besides declaring a single java.Object array for all three elements ?
> Thanks for the info.
> 
> Michael Nguyen,
> Frontier Solutions, Inc.
> 
> void Caller ()
> {
>   Class1 c1_array [] = new Class1[1], c1;
>   Class2 c2_array [] = new Class2[1], c2;
>   Class3 c3_array [] = new Class3[1], c3;
> 
>   c1 = c1_array[0];
>   c2 = c2_array[0];
>   c3 = c3_array[0];
>   // now use c1, c2, and c3
> }
> 
> void Calle (Class1 c1_array[], Class2 c2_array[], Class3 c3-array[])
> {
>   c1_array[0] = new Class1 ();
>   c2_array[0] = new Class2 ();
>   c3_array[0] = new Class3 ();
> }
Technical Details
Message-ID: <MPG.106698c69494aba698969a@forums.inprise.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <35F6C181.E937734@home.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,8f52af31779ed231
X-Google-Attributes: gidf74b3,public
From: mcgrath@enter.net (John P. McGrath)
Subject: Re: Returning Object Reference as parameters
Date: 1998/09/14
Message-ID: <MPG.106698c69494aba698969a@forums.inprise.com>
X-Deja-AN: 390921150
References: <35F6C181.E937734@home.com>
Organization: Software Consulting Services
Newsgroups: borland.public.jbuilder.java.language