Here you can find the source of distinct(List
public static List<String> distinct(List<String> list)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> distinct(List<String> list) { int m = 0; List<String> strList = new ArrayList<String>(); for (int i = 0; i < list.size(); i++) { for (int j = 0; j < list.size(); j++) { if (list.get(i).trim().equals(list.get(j).trim())) { if (i != j) { m = j;//ww w .ja v a 2 s . c o m list.remove(m); j--; } else { strList.add(list.get(i)); } } } } return strList; } }