List of usage examples for java.util ArrayDeque element
public E element()
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(25);/*w w w . j a v a 2 s. co m*/ deque.add(2); deque.add(1); deque.add(18); System.out.println(deque); // it will retrive element at first(head) position int retval = deque.element(); System.out.println("Retrieved Element is = " + retval); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testElement() { Object o1 = new Object(); Object o2 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); try {/*from w w w . j ava 2s .com*/ deque.element(); fail(); } catch (NoSuchElementException expected) { } deque.add(o1); assertEquals(o1, deque.element()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o1, deque.element()); checkDequeSizeAndContent(deque, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); try { deque.element(); fail(); } catch (NoSuchElementException expected) { } }