This Java Example shows how to copy all elements of ArrayDeque object to an Array object in java.
Copy ArrayDeque to an Array object Example
This Java Example shows how to copy all elements of ArrayDeque object to an
Array object in java. To copy the ArrayDeque elements to Array object we
use Object[] toArray( ) method. This method returns an array
containing all of the elements in this Deque in proper sequence.
Example: ArrayDequecopytoArray.java
package devmanuals.com; import java.util.*; public class ArrayDequecopytoArray { public static void main(String args[]) { ArrayDeque ADeque = new ArrayDeque(); ADeque.add("A"); ADeque.add("B"); ADeque.add("C"); ADeque.add("D"); System.out.println("The Array elements are :"); Object[] obj = ADeque.toArray(); for (int i = 0; i < obj.length; i++) { System.out.println(" " + obj[i]); } } }
Output:
The Array elements are : A B C D |
[ 0 ] Comments