Java: Unable to fix unchecked conversion required java.util.Collection
I have a Vector of Strings, oldV, and want a second Vector that is
identical but has all duplicates removed. The following works, in the
sense that it compiles and results in Vector that has the duplicates
removed:
Vector<String> newV = new Vector<String>( new LinkedHashSet(oldV) );
However, it generates two unchecked conversion warnings:
> warning: [unchecked] unchecked call to
LinkedHashSet(java.util.Collection<? extends E>) as a member of the raw
type java.util.LinkedHashSet
> warning: [unchecked] unchecked conversion
> found : java.util.LinkedHashSet
> required: java.util.Collection<? extends java.lang.String>
In both cases, the ^ is positioned directly under the "new" in "new
LinkedHashSet.
I'm at a loss of how to fix these warnings.
No comments:
Post a Comment