package devmanuals.com; import java.util.Deque; import java.util.LinkedList; import java.util.Iterator; public class DequePeekLast { public static void main(String args[]) { Deque dq = new LinkedList(); dq.add("11"); dq.add("DEV"); dq.add("MANUALS"); 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.peekLast(); System.out.println("Last element = " + obj); Iterator iq = dq.iterator(); while (iq.hasNext()) { dq.remove(); } System.out.println("Is Deque empty : " + dq.isEmpty()); // Here the implementation of peekLast() method will display null System.out.println("Therefore returns " +"'"+ dq.peekLast()+"'"); } }