Java List Distinct Value distinct(List list)

Here you can find the source of distinct(List list)

Description

distinct

License

Open Source License

Declaration

public static List<String> distinct(List<String> list) 

Method Source Code


//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;
    }
}

Related

  1. addDistinctItems(List fromItems, List toItems)
  2. addDistinctList(List sourceList, List entryList)
  3. addWithExpDecay(List distinctVals)
  4. constructDistinctClause(StringBuffer selectClause, List attributes, boolean isCountOnly)
  5. distinct(List list)
  6. distinct(List vector)
  7. distinctList(List sourceList)
  8. getDistinctStrings(String[] list)
  9. sortedDistinct(List seq)