Here you can find the source of unique(List
public static <E> List<E> unique(List<E> array)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <E> List<E> unique(List<E> array) { if (array == null) throw new NullPointerException("Not initizalize array"); List<E> uniq = new ArrayList<E>(); HashMap<E, Boolean> visited = new HashMap<E, Boolean>(); for (E s : array) { if (!visited.containsKey(s)) { uniq.add(s);/*from w w w. ja v a 2s . co m*/ visited.put(s, true); } } return uniq; } }