java remove duplicates

Java
import java.util.*;

public class RemoveDuplicatesFromArrayList {

    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(1,2,2,2,3,5);

        System.out.println(numbers);

        Set<Integer> hashSet = new LinkedHashSet(numbers);
        ArrayList<Integer> removedDuplicates = new ArrayList(hashSet);

        System.out.println(removedDuplicates);
    }
}
public static <T> ArrayList<T> removeDuplicates(ArrayList<T> list){
  Set<T> set = new LinkedHashSet<>(list);
  return new ArrayList<T>(set);
}
Source

Also in Java: