> Hi newsgroup,
>
[quoted text clipped - 6 lines]
> {
> Einl e = new Einl();
WhatTypeIs bO; // ???
> bO = e.bocreate();
return bO_OrSomethingElse; // ???
> }
> This works fine, but now I would like to also receive an integer created
> from the method e.bocreate().
What's the return type of bocreate()?
What does the integer represent? (maybe some count of matched items?)
> I know that the method bocreate() can only return one object, nevertheless I
> found some information about collections that could wrap more than one
> object.
>
> Does anyone know if it is possible to receive more than one object (with
> different object types) from one method?
That's not possible, a method returns nothing (void), a primitive or an
object (possibly null).
However, you can define a new class that holds both, and bocreate()
should return an instance of this class.
There are other possibilities too, including the use of a collection
class instance, or a 2 element Object array.
> Any help is greatly appreciated.
>
> Thanks very much in advance and best regards!
>
> Frank

Signature
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
Frank Meyer - 27 May 2005 21:13 GMT
Roland,
> > This works fine, but now I would like to also receive an integer created
> > from the method e.bocreate().
>
> What's the return type of bocreate()?
> What does the integer represent? (maybe some count of matched items?)
By now, the bocreate() returns an ArrayList which is written to bO... sorry,
my code was really misunderstandable...
The integer I'd like to get from bocreate() too represents an account
number, so it has nothing to do with the ArrayList already returned...
> That's not possible, a method returns nothing (void), a primitive or an
> object (possibly null).
[quoted text clipped - 4 lines]
> There are other possibilities too, including the use of a collection
> class instance, or a 2 element Object array.
Well, after having read some information about the Collection, I think I
would use this way... which means that bocreate() has to put the ArrayList
and the integer in a new Collection object and return this to bORead(),
which will have to get the two out of the Collection, right?
I'll try tomorrow...
Many thanks so far and a very nice weekend!
Best regards
Frank
Dale King - 31 May 2005 12:46 GMT
> Roland,
>
[quoted text clipped - 9 lines]
> The integer I'd like to get from bocreate() too represents an account
> number, so it has nothing to do with the ArrayList already returned...
Then it sounds like returning it should not be part of this method. Each
method should only do one thing. A little test I use is to see if you
can come up with a simple name for the multiple things you are trying to
return without using the word "and". If not that's a red flag saying
that you probably are trying to do something wrong.
It sounds like you have a design problem and we can't really help you
with that without understanding what it is you are trying to do in the
actual program.

Signature
Dale King
> Hi newsgroup,
>
[quoted text clipped - 24 lines]
>
> Frank
You can do this if you return a Collection of Objects. For example you
could have a Vector. You would need some wrapper class though to tell you
what type of data each entry holds but other than that - its trivial.
Allan
Frank Meyer - 27 May 2005 22:08 GMT
Allan,
> You can do this if you return a Collection of Objects. For example you
> could have a Vector. You would need some wrapper class though to tell you
> what type of data each entry holds but other than that - its trivial.
guess what? I chose the Vector Object as my solution in the meanwhile... and
it works :o)
The only thing of importance was the usage of a Integer class object for the
int value...
Java can be so easy if you know ;o)
A nice weekend!
Best regards
Frank