Here you can find the source of unique(Collection
public static <T> Collection<T> unique(Collection<T> c)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> Collection<T> unique(Collection<T> c) { if (c != null && c.size() > 0) { Map<T, Integer> map = new LinkedHashMap<T, Integer>(); for (T o : c) { map.put(o, 0);// ww w. j a v a 2 s.c o m } return new ArrayList<T>(map.keySet()); } return c; } }