Depends. If the returned types are two unrelated types then you'd have to return an Object, which negates the value of type safety, IDE support, etc. I tend to use inner classes or utility classes instead--but that's just me.
Objects that manage pairs of items or values are quite
common. They are also easy to expand (extend) to handle
more items and mixed item types. So by using an object
you are on a very good track.
Jim ... ...
BEE MBA PMP SCJP-6
Joined: Jun 28, 2009
But should i use a collection or just an object array would suffice for two objects
What advantage this has over using Object array. I agree there is type checking and meaningful getters. But, for one time returning of two objects, which is preferable. I mean, i would like to know the pros and cons of each