Reputation: 6656
I am getting warning from eclipse
Type safety: The expression of type TreeItem[] needs unchecked conversion to conform to TreeItem<AppleItem>[]
while using this:
TreeItem<AppleItem>[] friends = item.getChildren().toArray(new TreeItem[0]);
I dont want to use @uncheck
or I dont want to use a loop for inserting one by one. Is there a way to do this?
Appearantly getChildren
returns an ArrayList
like ArrayList<TreeItem<AppleItem>>
Thanks in advance.
Upvotes: 0
Views: 419
Reputation: 198211
Nope, there's no way to do it without an unchecked cast. @Ivaylo's solution won't save you from casting, either.
Upvotes: 1