Adds all of the elements in the specified collection at the end of this deque, in the order that they are returned by the collection's iterator.
package com.logicbig.example.arraydeque;
import java.util.ArrayDeque;
import java.util.List;
public class AddAllExample {
public static void main(String... args) {
List<Integer> list = List.of(6, 1, 5);
System.out.println("List: " + list);
ArrayDeque<Integer> ad = new ArrayDeque<>();
ad.addAll(list);
System.out.println("ArrayDeque: " + ad);
}
}
Output
List: [6, 1, 5]
ArrayDeque: [6, 1, 5]
package com.logicbig.example.arraydeque;
import java.util.ArrayDeque;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
public class AddAllExample2 {
public static void main(String... args) {
SortedSet<Integer> set = new TreeSet<>(Set.of(6, 1, 5));
System.out.println("SortedSet: " + set);
ArrayDeque<Integer> ad = new ArrayDeque<>();
ad.addAll(set);
System.out.println("ArrayDeque: " + ad);
}
}
Output
SortedSet: [1, 5, 6]
ArrayDeque: [1, 5, 6]