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.
Joined: Jan 09, 2008
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
Joined: Oct 13, 2005
I would use an object which encapsulates the two values, not an array or collection.
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