Java Collection Tutorial - Java ArrayDeque(Collection <? extends E > c) Constructor








Syntax

ArrayDeque(Collection <? extends E > c) constructor from ArrayDeque has the following syntax.

public ArrayDeque(Collection <? extends E> c)

Example

In the following code shows how to use ArrayDeque.ArrayDeque(Collection <? extends E > c) constructor.

//from   ww  w.j  a  v  a 2 s  .co m
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;

public class Main {
  public static void main(String[] args) {
    Collection<Integer> col = new ArrayList<Integer>();
    col.add(0);
    Deque<Integer> deque = new ArrayDeque<Integer>(col);

    deque.add(3);
    deque.add(18);
    deque.add(25);
    deque.add(18);

    System.out.println(deque);
    
    
  }
}

The code above generates the following result.