Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.HashSet; public class Main { public static void uniqe(ArrayList<String> queryDoc) { // add elements to al, including duplicates HashSet<String> hs = new HashSet<String>(); hs.addAll(queryDoc); queryDoc.clear(); queryDoc.addAll(hs); } }