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.
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.
The ArrayDeque: [Welcome, To, Geeks, For, Geeks] The array is: Welcome To Geeks For Geeks
The ArrayDeque: [10, 15, 30, 20, 5, 25] The array is: 10 15 30 20 5 25
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.