package devmanuals.com; import java.util.Queue; import java.util.LinkedList; import java.util.Iterator; public class QueuePeek { public static void main(String args[]) { Queue q = new LinkedList(); q.add("A"); q.add("B"); q.add("C"); q.add("D"); q.add("E"); System.out.println("Is Queue empty : " + q.isEmpty()); System.out.println("Elements of queue = " + q); System.out.println("Size of Queue : " + q.size()); Object obj = q.peek(); System.out.println("Element at head position = " + obj); Iterator iq = q.iterator(); while (iq.hasNext()) { q.remove(); } System.out.println("Is Queue empty : "+q.isEmpty()); // Here the implementation of peek() method will display null System.out.println(q.peek()); } }