简体   繁体   中英

Error using Java generics, ? extends clause

I have got a treeitem object with user object of type MyNode :

final TreeItem<? extends MyNode> parent = treeItem.getParent();
final ObservableList<TreeItem<? extends MyNode>> children = parent.getChildren();

Using the ? extends ? extends in java generics gives me the following error:

Found: ObservableList<javafx.scene.control.TreeItem<? extends MyNode>>
Required: ObservableList<javafx.scene.control.TreeItem<capture <? extends MyNode>>>

Any suggestions?

Try:

final ObservableList<? extends TreeItem<? extends MyNode>> children = parent.getChildren();

it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM