src/share/classes/java/util/AbstractCollection.java

Print this page

        

@@ -356,10 +356,11 @@
      *
      * @see #remove(Object)
      * @see #contains(Object)
      */
     public boolean removeAll(Collection<?> c) {
+        Objects.requireNonNull(c);
         boolean modified = false;
         Iterator<?> it = iterator();
         while (it.hasNext()) {
             if (c.contains(it.next())) {
                 it.remove();

@@ -389,10 +390,11 @@
      *
      * @see #remove(Object)
      * @see #contains(Object)
      */
     public boolean retainAll(Collection<?> c) {
+        Objects.requireNonNull(c);        
         boolean modified = false;
         Iterator<E> it = iterator();
         while (it.hasNext()) {
             if (!c.contains(it.next())) {
                 it.remove();