Here you can find the source of removeDuplicates(ArrayList
public static <T> ArrayList<T> removeDuplicates(ArrayList<T> a)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static <T> ArrayList<T> removeDuplicates(ArrayList<T> a) { ArrayList<T> result = new ArrayList<T>(); for (T t : a) if (!result.contains(t)) result.add(t);// w w w. j a v a 2s . co m return result; } }