Java List Uniqne Item uniqueList(Collection

list)

Here you can find the source of uniqueList(Collection

list)

Description

Remove all duplicated entries.

License

Open Source License

Parameter

Parameter Description
list a parameter

Declaration

public static <P> Collection<P> uniqueList(Collection<P> list) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    /**/*from ww w.  j  av a 2  s. c om*/
     * Remove all duplicated entries.
     * 
     * @param list
     * @return
     */
    public static <P> Collection<P> uniqueList(Collection<P> list) {

        ArrayList<P> uniqueList = new ArrayList<>();
        for (P item : list) {
            if (uniqueList.contains(item)) {
                continue;
            }
            uniqueList.add(item);
        }
        return uniqueList;
    }
}

Related

  1. unique(List array)
  2. unique(List entities)
  3. unique(List list)
  4. uniqueList(List list)
  5. uniqueListInsert(List list1, List list2)
  6. uniqueMacTest(List macs, String attempt)