import java.util.*; //Implementation of a Queue (First In First Out List) of Objects public class Queue { //Instance Variable: Stores the Objects added into this Stack private LinkedList store; public Queue() { this.store = new LinkedList(); } //Answers true iff this Queue is empty public boolean isEmpty() { return this.store.isEmpty(); } //Accessor: Returns the Object at the HEAD without removing it // Returns null if this Queue is empty public Object peek() { if (this.store.isEmpty()) return null; return this.store.getFirst(); } //Mutator: Adds an Object to the REAR of this Queue public void enQueue(Object item) { this.store.addLast(item); } //Mutator: Removes and returns the Object from the HEAD of this Queue // Throws a "Queue Underflow" Exception if this Queue is empty public Object deQueue() { if (this.store.isEmpty()) throw new RuntimeException("Queue Underflow"); return this.store.removeFirst(); } }