Eclipse:修复“类型参数的冗余规范”会导致错误

时间:2018-07-03 11:52:25

标签: java eclipse

Eclipse(Oxygen.2)显示以下代码段的“类型参数的冗余说明”警告。修复时,通过使用new Element<>(),在下一行会出现编译时错误,因为它无法推断类型,而是使用Element<Object>且列表为Element<A>

public static void main(String[] args)
{
  List<Element<A>> list = new ArrayList<>();
  Stream.of("foo", "bar")
    .map(e -> new Element<A>())
    .forEach(list::add);
}

interface A
{}

private static class Element<A>
{
  public Element()
  {}
}

IntelliJ不建议删除该类型。这是Eclipse的问题吗?

0 个答案:

没有答案