package devmanuals.com; import java.util.Deque; import java.util.LinkedList; import java.util.Iterator; public class DequePop { public static void main(String[] args) { Deque dq = new LinkedList(); dq.add(-1); dq.add(0); dq.add(1); dq.add(2); dq.add(3); System.out.println("Is deque empty : " + dq.isEmpty()); System.out.println("Elements of deque : " + dq); System.out.println("Size of deque before removing an element : " + dq.size()); System.out .println("Now after removing the element from the deque new deque is "); Object obj = dq.pop(); System.out.println(dq); System.out.println("Removed element is = " + obj); System.out.println("Size of deque after removing element : " + dq.size()); //Removes all the elements from deque Iterator it = dq.iterator(); while (it.hasNext()) { dq.pop(); } System.out.println("Elements in deque = "+dq); System.out.println("Is deque empty : " + dq.isEmpty()); // Here implementation of the pop( ) method will display 'null' System.out.println(dq.pop()); } }