package lists; public class Queue implements ADTQueue { private Node tail; private Node head; public Queue() { tail = null; head = null; } public Object dequeue() { Node p = head; if (head == tail) { head = null; tail = null; } else { head = head.getNext(); } p.setNext(null); return p.getData(); } public void enqueue(Object obj) { Node p = new Node(obj); if (head == null) head = p; else tail.setNext(p); tail = p; } public boolean isEmpty() { return (head == null); } public Object peek() { return head.getData(); } }