Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; public class Main { public static <T> boolean isDistinct(Collection<T> in) { if (in == null) { return true; } return in.size() == distinct(in).size(); } public static <T> List<T> distinct(Collection<T> in) { if (in == null) { return new ArrayList<T>(); } return new ArrayList<T>(new HashSet<T>(in)); } }