Example usage for java.util Deque element

List of usage examples for java.util Deque element

Introduction

In this page you can find the example usage for java.util Deque element.

Prototype

E element();

Source Link

Document

Retrieves, but does not remove, the head of the queue represented by this deque (in other words, the first element of this deque).

Usage

From source file:Main.java

public static void main(String[] args) {

    Deque<Integer> deque = new ArrayDeque<Integer>(8);

    deque.add(1);//from  w  ww.java 2s .  c om
    deque.add(2);
    deque.add(3);
    deque.add(4);

    System.out.println(deque);

    int retval = deque.element();
    System.out.println("Retrieved Element is = " + retval);
}