Here you can find the source of removeDuplicates(List
Parameter | Description |
---|---|
commonVars | a parameter |
public static List<String> removeDuplicates(List<String> commonVars)
//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; } }