Online Java Compiler By
JavaTpoint.com
import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueAddAllExample1 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); List
list = new ArrayList
(); System.out.println(" Before applying addAll() : " ); System.out.println("Elements in queue : "+ queue); for (int i = 1; i <11; i++) { int j = i *5; list.add(j); } System.out.println("Elements in list : "+list); System.out.println(); System.out.println(" After applying addAll : "); //will add all the elements int the queue which are present in list queue.addAll(list); System.out.println("Elements in queue : " + queue); System.out.println("Elements in list : "+list); } }
Output