The java.util Queue addAll() method adds all elements of a specified collection to the end of the queue. It returns a boolean value, true if the queue changed as a result of the call.
Example:
Queue queue1 = new LinkedList<>(); queue1.add("element1"); queue1.add("element2");
Queue queue2 = new LinkedList<>(); queue2.add("element3"); queue2.add("element4");
queue1.addAll(queue2); // add all elements of queue2 to queue1
In this example, we created two queues and added some elements to them. We then used the addAll() method to add all elements of queue2 to queue1. Finally, we printed out the elements in queue1 to verify that the elements from queue2 were added successfully.
The java.util package is used in this example.
Java Queue.addAll - 30 examples found. These are the top rated real world Java examples of java.util.Queue.addAll extracted from open source projects. You can rate examples to help us improve the quality of examples.