Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在eclipse中如何克服类型安全警告而不忽略它?_Java_Eclipse_Casting - Fatal编程技术网

Java 在eclipse中如何克服类型安全警告而不忽略它?

Java 在eclipse中如何克服类型安全警告而不忽略它?,java,eclipse,casting,Java,Eclipse,Casting,我收到日食的警告 类型安全性:类型TreeItem[]的表达式需要未经检查的转换才能符合TreeItem[] 在使用时: TreeItem<AppleItem>[] friends = item.getChildren().toArray(new TreeItem[0]); TreeItem[]friends=item.getChildren().toArray(新的TreeItem[0]); 我不想使用@取消选中,也不想使用循环逐个插入。有办法做到这一点吗 显然getChild

我收到日食的警告

类型安全性:类型TreeItem[]的表达式需要未经检查的转换才能符合TreeItem[]

在使用时:

TreeItem<AppleItem>[] friends = item.getChildren().toArray(new TreeItem[0]);
TreeItem[]friends=item.getChildren().toArray(新的TreeItem[0]);
我不想使用
@取消选中
,也不想使用循环逐个插入。有办法做到这一点吗

显然
getChildren
返回一个
ArrayList
类似
ArrayList


提前谢谢。

不,如果没有未经检查的演员阵容,就没有办法做到这一点@Ivaylo的解决方案也不会让你免于选角。

我想是的,但我想确定的是,如果你认为你绝对肯定,你应该把它作为答案发布,这样我就接受了。ty Btwarray和泛型在Java中不能很好地混合,因此最好尽量避免使用对象数组。你真的需要一个数组吗?你不能继续使用ArrayList吗?事实上dat ArrayList是一个可观察的类型,所以我必须使用它,但是ty是提供的