Here you can find the source of removeDuplicates(ArrayList
public static ArrayList<String> removeDuplicates(ArrayList<String> al)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static ArrayList<String> removeDuplicates(ArrayList<String> al) { Set<String> hs = new HashSet<>(); hs.addAll(al);//from w ww . j a va2 s.co m al.clear(); al.addAll(hs); return al; } }