jdk/src/share/classes/java/util/ArrayList.java
changeset 17441 5ae43433d158
parent 17432 efdf6eb85a17
child 18829 ec84f0c313b0
equal deleted inserted replaced
17440:fb37aa6b305e 17441:5ae43433d158
   669      * (<a href="Collection.html#optional-restrictions">optional</a>),
   669      * (<a href="Collection.html#optional-restrictions">optional</a>),
   670      *         or if the specified collection is null
   670      *         or if the specified collection is null
   671      * @see Collection#contains(Object)
   671      * @see Collection#contains(Object)
   672      */
   672      */
   673     public boolean removeAll(Collection<?> c) {
   673     public boolean removeAll(Collection<?> c) {
       
   674         Objects.requireNonNull(c);
   674         return batchRemove(c, false);
   675         return batchRemove(c, false);
   675     }
   676     }
   676 
   677 
   677     /**
   678     /**
   678      * Retains only the elements in this list that are contained in the
   679      * Retains only the elements in this list that are contained in the
   689      * (<a href="Collection.html#optional-restrictions">optional</a>),
   690      * (<a href="Collection.html#optional-restrictions">optional</a>),
   690      *         or if the specified collection is null
   691      *         or if the specified collection is null
   691      * @see Collection#contains(Object)
   692      * @see Collection#contains(Object)
   692      */
   693      */
   693     public boolean retainAll(Collection<?> c) {
   694     public boolean retainAll(Collection<?> c) {
       
   695         Objects.requireNonNull(c);
   694         return batchRemove(c, true);
   696         return batchRemove(c, true);
   695     }
   697     }
   696 
   698 
   697     private boolean batchRemove(Collection<?> c, boolean complement) {
   699     private boolean batchRemove(Collection<?> c, boolean complement) {
   698         final Object[] elementData = this.elementData;
   700         final Object[] elementData = this.elementData;