In one word, what's wrong with this method?
Idea is that it should return a list that contains no duplicates
In anticipation of why i think there is something wrong with it, the following is a warning i get "Type safety: Unchecked cast from HashSet<String> to List<String>"Code:private List<String> uniqueArguments(ArrayList<String> arrayList) {
List<String> noDups = (List<String>) new HashSet<String>(arrayList);
return noDups;
}
And also, it does not work :(
Exception in thread "main" java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List
1 more comment, sysouts work and print what's expected, but stillCode:private List<String> uniqueArguments(ArrayList<String> arrayList) {
System.out.println(arrayList);
HashSet<String> noDups = new HashSet<String>(arrayList);
System.out.println(noDups);
return (List<String>) noDups;
}
Exception in thread "main" java.lang.ClassCastException: java.util.HashSet cannot be cast to java.util.List

