Java List Remove Duplicate removeDuplicates(List commonVars)

Here you can find the source of removeDuplicates(List commonVars)

Description

removes duplicated vars in a list

License

Apache License

Parameter

Parameter Description
commonVars a parameter

Return

a list of variables without duplicates

Declaration

public static List<String> removeDuplicates(List<String> commonVars) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*w  w w .j a v a  2s  .com*/
     * removes duplicated vars in a list
     * 
     * @param commonVars
     * @return a list of variables without duplicates
     */
    public static List<String> removeDuplicates(List<String> commonVars) {
        List<String> sList = new ArrayList<String>();

        for (String s : commonVars) {
            if (sList.contains(s)) {
                // sList.add(s);
                // commonVars.remove(s);
            } else {
                sList.add(s);
            }
        }
        return sList;
    }
}

Related

  1. removeDuplicate(List uidList)
  2. removeDuplicate(List dest, List src)
  3. removeDuplicates(int[] list)
  4. removeDuplicates(List list)
  5. removeDuplicates(List listofthings)
  6. removeDuplicates(List l)
  7. removeDuplicates(List collection)
  8. removeDuplicates(List list)
  9. removeDuplicates(List list, Comparator comparator)