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