Jus*_*ing 1 java android asynchronous callable
如何使以下Java代码工作:
public class Worker implements Callable<myObject>{
@Override
public ArrayList<myObject> call() throws Exception {
ArrayList<myObject> lst_MyObjects= new ArrayList<myObject>();
return lst_MyObjects;
}
}
Run Code Online (Sandbox Code Playgroud)
错误:返回类型与Callable.call()不兼容
我只想返回一个特定类型的容器(Vector<>/ ArrayList<>等)
只要用这个:
public class Worker implements Callable<List<myObject>>{
Run Code Online (Sandbox Code Playgroud)
通过使用List,您可以返回a ArrayList或a Vector,但建议使用ArrayList而不是a Vector.
| 归档时间: |
|
| 查看次数: |
617 次 |
| 最近记录: |