Removes
all of this collection's elements that are also contained in the specified collection.

package com.logicbig.example.arraydeque;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Set;
public class RemoveAllExample3 {
public static void main(String... args) {
ArrayDeque<Integer> ad = new ArrayDeque<>(List.of(3, 8, 1));
System.out.println(ad);
boolean b = ad.removeAll(Set.of(8, null));
System.out.println(b);
System.out.println(ad);
}
}
Output
[3, 8, 1]
java.lang.NullPointerException
at java.util.Objects.requireNonNull (Objects.java:220)
at java.util.ImmutableCollections$Set12.<init> (ImmutableCollections.java:1016)
at java.util.Set.of (Set.java:487)
at com.logicbig.example.arraydeque.RemoveAllExample3.main (RemoveAllExample3.java:17)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:565)
at org.codehaus.mojo.exec.AbstractExecJavaBase.executeMainMethod (AbstractExecJavaBase.java:402)
at org.codehaus.mojo.exec.ExecJavaMojo.executeMainMethod (ExecJavaMojo.java:142)
at org.codehaus.mojo.exec.AbstractExecJavaBase.doExecClassLoader (AbstractExecJavaBase.java:377)
at org.codehaus.mojo.exec.AbstractExecJavaBase.lambda$execute$0 (AbstractExecJavaBase.java:287)
at java.lang.Thread.run (Thread.java:1474)
JDK 25