Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Main { public static <E, T extends Collection<E>> void removeDuplicates(T collection) { final Set<E> set = new HashSet<>(collection); collection.clear(); collection.addAll(set); } }