从不同的地方调用时,不能在方法参数中使用List <Future <?>>

Ang*_*chs 6 java generics list

在我的代码中,我有多个实例,List<Future<something>>我希望有一个方法来处理等待它们完成.但我得到一个编译器异常告诉我actual argument List<Future<Boolean>> cannot be converted to List<Future<?>>.

这是方法头:

public void waitForIt(<List<Future<?>> params)
Run Code Online (Sandbox Code Playgroud)

这就是它的名称:

...
List<Future<Boolean>> actions = new ArrayList<Future<Boolean>>();
waitForIt(actions); <-- compiler error here
...
Run Code Online (Sandbox Code Playgroud)

我需要这个List<Future<Map<String, String>>>和其他几个人一起工作.

gui*_*ido 2

用这个:

public <T> void waitForIt(List<Future<T>> params)
Run Code Online (Sandbox Code Playgroud)

因为Future<Boolean>不是延伸Future<?>

http://ideone.com/tFECPN