我收到此编译器警告。这是我使用的接口和方法的类(其他人员省略):
public class Controller extends BaseController {
//interface
public interface MyInterface<T extends Iterable<? super T>> {
List<T> getList();
}
//method call
updateJoinTable(request.getProductGrades().size(), instance::getProductGrades);
//method
private static void updateJoinTable(Integer LastValidElement, MyInterface myInterface) {
myInterface.getList().subList(LastValidElement, myInterface.getList().size())
.forEach(i ->myInterface.getList().remove(i));
}
}
forEach 的最后一部分引起警告。
现在,起初代码没有:
<T extends Iterable<? super T>>
但是我在 SO 上看到了很多类似的案例,主要是具有可比性,我通过阅读解决方案了解到,这个问题是我的泛型类型绑定到一个本身有类型的类型,但我没有提供一个,所以它是原始的 - 然后我将该行添加到界面并预期警告消失。但它仍然存在。你有什么想法我应该怎么做才能摆脱它?
慕桂英546537
相关分类