whats the best way to remove duplicates from arraylist code example
Example: java remove duplicates
public static <T> ArrayList<T> removeDuplicates(ArrayList<T> list){
Set<T> set = new LinkedHashSet<>(list);
return new ArrayList<T>(set);
}
public static <T> ArrayList<T> removeDuplicates(ArrayList<T> list){
Set<T> set = new LinkedHashSet<>(list);
return new ArrayList<T>(set);
}