我遇到以下情况的问题:
private static List<? extends Object> function1(final Collection<? extends Object>... collections) {
final List<Object> result = new ArrayList<Object>();
// do some work
return result;
}
public static List<? extends Object> function2(final Collection<? extends Object>... collections) {
// do some work
return function1(collection);
}
在最后一行,错误是Type mismatch: cannot convert from Pair<String,List<capture#74-of ? extends Object>> to Pair<String,List<? extends Object>>
如何正确定义泛型?
更新:应该可以在调用中使用不同的集合类型function1(Collection<Long>, Collection<String>)