Java Collection Tutorial - Java BlockingDeque.element()








Syntax

BlockingDeque.element() has the following syntax.

E element()

Example

In the following code shows how to use BlockingDeque.element() method.

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/*from w  w  w.  j a v a2  s  .c  o m*/
public class Main {
  public static void main(String[] argv) throws Exception {
    int capacity = 10;
    BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
      queue.add(i);
    }
    
    System.out.println(queue.element());
  }
}

The code above generates the following result.