Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionAddAllExample3 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); Deque
deque=new ArrayDeque<>(); for (int i=0;i<=5;i++){ queue.add(i); } //will give an error for null elements deque.add(null); queue.addAll(deque); System.out.println(queue); } }
Output