The actual collection implementation you use inside your class is completely immaterial to the clients/users of the class as long as your interface definition accepts Collection
, i.e.
void buy(int n, List<T> items)
void sell(List<T> items)
should be
void buy(int n, Collection<T> items)
void sell(Collection<T> items)
This will not restrict anyone to use only List
types. Then, your internal member stock
can be and should be instantiated with any concrete subtype of Collection
.