java - How do i get Vector<type> Arraylist<type> as return of call()? -


how following java code work:

public class worker implements callable<myobject>{     @override    public arraylist<myobject> call() throws exception {       arraylist<myobject> lst_myobjects= new arraylist<myobject>();            return lst_myobjects;    } } 

error: return type incompatible callable.call()

i want return container of specific type (vector<> / arraylist<> etc.)

just use this:

public class worker implements callable<list<myobject>>{ 

by using list, can return either arraylist or vector, though advisable use arraylist instead of vector.


Comments