Can a method return more than one object?

For instance, I have a Vector return value on a method. Can I initialize and set four different vectors within one call of the method? This is a bean so if this is true, how can I distinguish between them after the call on the jsp? It smells to me a little bit to have four different methods within the bean compile four different vectors. Thank you very much for reading this question.

[393 byte] By [wecoxepa] at [2007-9-30 19:51:12]
# 1
put the 4 of them in an Array or Hash Map .... you can distinguish them by their index or by the "name" you give them.... but no... a method can not return more than one object (even a beginner java programmer knows this... jeez....)
dknightx at 2007-7-7 0:38:40 > top of Java-index,Java Essentials,Java Programming...
# 2

First of all, methods cannot return Objects at all.

Methods can only return a single primitive, or a single reference to an object.

If you are always going to return 4 Vectors, then why not return an array of

Vectors. The real question is: Does it make sense to return all four vectors

from the same method. If the four Vectors are not related to each other, then

they probably should be returned from different methods. It all depends on

what the four Vectors contain and how their contents relate to each other.]

Without knowing that information, I can't tell which way I think is better.

whoisfred at 2007-7-7 0:38:40 > top of Java-index,Java Essentials,Java Programming...
# 3
Or void.%
duffymo at 2007-7-7 0:38:40 > top of Java-index,Java Essentials,Java Programming...
# 4
You could also create a class that encapsulates the four objects, and return one of those.
nasch_ at 2007-7-7 0:38:40 > top of Java-index,Java Essentials,Java Programming...
# 5

Thanks for the info guys. Hey dknightx, thanks for the extraneous commentary...the aim of my question was if I could initialize and create four different vectors within a single method. Then I asked if so, how could I distinguish between them when they are returned (I should have stated explicitly these would be returned within a single vector or whatever the return type would be on the methiod...probably a hashset).

wecoxepa at 2007-7-7 0:38:40 > top of Java-index,Java Essentials,Java Programming...