title: How to pop items from a collection in Java?
body: <p>Is there a method in JDK or apache commons to "pop" a list of elements from a java.util.List? I mean, remove the list of elements and return it, like this method:</p>
  
  <pre><code>public Collection pop(Collection elementsToPop, Collection elements) {
  
    Collection popped = new ArrayList();
  
    for (Object object : elementsToPop) {
      if (elements.contains(object)) {
        elements.remove(object);
        popped.add(object);
      }
    }
  
    return popped;
  }
  </code></pre>