package devmanuals.com; import java.util.Deque; import java.util.LinkedList; import java.util.Iterator; public class DequeElement { public static void main(String args[]) { Deque dq = new LinkedList(); dq.add("He"); dq.add("is "); dq.add("a"); dq.add("boy"); System.out.println("Is Deque empty : " + dq.isEmpty()); System.out.println("Elements of Deque = " + dq); System.out.println("Size of Deque : " + dq.size()); Object obj = dq.element(); System.out.println("Element at head position = " + obj); Iterator idq = dq.iterator(); while (idq.hasNext()) { dq.remove(); } System.out.println("Is Deque empty : " + dq.isEmpty()); // Here the implementation of element() method will display exception System.out.println(dq.element()); } }