Reputation: 6236
I have collection of Set
and List
so how can call a function who accept any type of collection ?
Set<X> myset = ...;
myfunction(myset);
List<X> mylist = ...;
myfunction(mylist);
myfunction(T collection){
}
So what would be the type of T ?
Upvotes: 1
Views: 460
Reputation: 311188
If you aren't using generics, T is simply a Collection
:
void myfunction(Collection collection)
If you are, you could use T extends Collection
<T extends Collection> void myfunction(T collection)
Upvotes: 0