public class QueueExample {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Queue<String>qe=new LinkedList<String>() ;
qe.add("b");
qe.add("a");
qe.add("c");
qe.add("e");
qe.add("d");
Iterator it=qe.iterator();
System.out.println("Iterator Size of Queue :"+qe.size());
while(it.hasNext())
{
String iteratorValue=(String)it.next();
System.out.println("Queue Next Value:"+iteratorValue);
}
System.out.println("Queue peek:"+qe.peek());
System.out.println("Queue poll:"+qe.poll());
System.out.println("Final Size of Queue:"+qe.size());
}
}
add some code in the main to test all the queue features
employ the above skeleton to build a system keeps track for customers which may help a cashier a very crowded shop to serve first who came earliest
