The
java.util.ArrayDeque.toArray() method is used to form an array of the same elements as that of the Deque. Basically, the method copies all the element from this deque to a new array.
Syntax:
Object[] arr = Array_Deque.toArray()
Parameters: The method does not take any parameters.
Return Value: The method returns an array containing the elements present in the ArrayDeque.
Below programs illustrate the java.util.ArrayDeque.toArray() method.
Program 1:
Output:
The ArrayDeque: [Welcome, To, Geeks, For, Geeks]
The array is:
Welcome
To
Geeks
For
Geeks
Program 2: