我收到来自 eclipse 的警告
Type safety: The expression of type TreeItem[] needs unchecked conversion to conform to TreeItem<AppleItem>[]
使用时:
TreeItem<AppleItem>[] friends = item.getChildren().toArray(new TreeItem[0]);
我不想使用@uncheck
或者我不想使用循环来逐一插入。有办法做到这一点吗?
显然getChildren
返回 ArrayList
喜欢 ArrayList<TreeItem<AppleItem>>
提前致谢。
最佳答案
不,如果没有未经检查的 Actor 阵容,就没有办法做到这一点。 @Ivaylo 的解决方案也无法让您免于选角。
关于java - 如何在 Eclipse 中克服类型安全警告而不忽略它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14899654/