Here you can find the source of unique(Collection
@SuppressWarnings("unchecked") public static <T> Collection<T> unique(Collection<T> c, Collection<T> result)
//package com.java2s; import java.util.*; public class Main { @SuppressWarnings("unchecked") public static <T> Collection<T> unique(Collection<T> c, Collection<T> result) { if (c == null) { return result; }//from w w w .j a v a 2 s .com Set<T> s = new LinkedHashSet<T>(c); result.addAll(s); return result; } }