I was recently told that collection should be preferred to List as the return value of an EJB method. The argument is that in general collection is more generic i.e. gives you t
Then you usually have 4 options: List
, Set
, Collection
and Iterable
. There it depends what is the semantics you want to include.
Set
List
Collection
Iterable
(Note: there are some collection interfaces with more specific semantics: Queue
, Deque
, Map
, Bag
, Multiset
, etc. - but it will be fairly obvious when you need to return them)