ArrayDeque.clone() has the following syntax.
public ArrayDeque <E> clone()
In the following code shows how to use ArrayDeque.clone() method.
//from w w w . java2 s . c o m import java.util.ArrayDeque; import java.util.Deque; public class Main { public static void main(String[] args) { ArrayDeque<Integer> deque1 = new ArrayDeque<Integer> (8); deque1.add(3); deque1.add(2); deque1.add(1); deque1.add(18); // clone the first deque, Deque<Integer> deque2 = deque1.clone(); // print all the elements available in deque2 System.out.println(deque2); } }
The code above generates the following result.