Java List Remove removeElementsFromList(List inputList, List elementsToRemove)

Here you can find the source of removeElementsFromList(List inputList, List elementsToRemove)

Description

remove Elements From List

License

Open Source License

Declaration

public static <T> List<T> removeElementsFromList(List<T> inputList, List<T> elementsToRemove) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static <T> List<T> removeElementsFromList(List<T> inputList, List<T> elementsToRemove) {
        if (elementsToRemove == null) {
            return inputList;
        }/*from   w w w.jav  a  2 s .com*/
        List<T> filteredList = new ArrayList<T>(inputList);
        for (Object objectToRemove : elementsToRemove) {
            for (int i = 0; i < filteredList.size(); i++) {
                if (filteredList.get(i).equals(objectToRemove)) {
                    filteredList.remove(i);
                }
            }
        }
        return filteredList;
    }
}

Related

  1. removeAllNull(List list)
  2. removeAllNulls(List list)
  3. removeBlankLine(List lines)
  4. removeByRef(List list, Object obj)
  5. removeElement(T element, List list)
  6. removeEmpties(List original)
  7. removeEmpty(List strings)
  8. removeEmptyColumns(List data)
  9. removeEmptyLines(List lines)