我在getNodes()
方法中遇到错误。 ***
The method getfilter(ListView<CellObject>) in the type NodeUtil is not
applicable for the arguments (ListView<Index>)
但是,由于Index
实施CellObject
,而Employee
延伸Index
,它应该有效吗?
public abstract class Index implements CellObject {
}
...
@FXML private ListView <Index> listView;
public List<Node> getNodes() {
List<Node> nodes = new ArrayList<>();
***nodes.add(NodeUtil.getfilter(listView));***
return nodes;
}
public class Employee extends Index {
@Override
public String getInfo() {
return name + address;
}
}
public abstract class NodeUtil {
public static List <Node> getfilter(ListView <CellObject> lv) {
...
lv.getItems().stream()
.filter(c -> c.getInfo().contains("xxx"))
...
}
}
答案 0 :(得分:0)
在泛型中,您必须指定是否需要特定类型或extends
某种类型的类型,请使用此项:
public static List <Node> getfilter(ListView < ? extends CellObject > lv) {