VOOZH about

URL: https://www.geeksforgeeks.org/java/arraydeque-toarray-method-in-java/

⇱ ArrayDeque toArray() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ArrayDeque toArray() Method in Java

Last Updated : 10 Dec, 2018
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:
Output:
The ArrayDeque: [10, 15, 30, 20, 5, 25]
The array is:
10
15
30
20
5
25
Comment