Type accepting any collection

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 ?

Answer

Collection. List and Set interfaces extends Collection.

Leave a Reply

Your email address will not be published. Required fields are marked *