public class LLQueue implements QueueInterface { LinkedList queueLL; @Override public int size() { return queueLL.size(); } @Override public boolean isEmpty() { return size()==0; } @Override public E first() { if (isEmpty()) return null; return queueLL.first(); } @Override public void enqueue(E e) { queueLL.addLast(e); } @Override public E dequeue() { if (isEmpty()) return null; return queueLL.removeFirst(); } public LLQueue() { queueLL = new LinkedList(); } @Override public String toString() { return queueLL.toString(); } public static void main(String[] args) { LLQueue qqq = new LLQueue<>(); qqq.enqueue(5); System.out.println(qqq); qqq.enqueue(3); System.out.println(qqq); qqq.dequeue(); System.out.println(qqq); qqq.enqueue(7); System.out.println(qqq); qqq.dequeue(); System.out.println(qqq); System.out.println("First:"+qqq.first()); qqq.dequeue(); System.out.println(qqq); qqq.dequeue(); System.out.println(qqq.isEmpty()); qqq.enqueue(9); System.out.println(qqq); qqq.enqueue(7); System.out.println(qqq); System.out.println("Size: " + qqq.size()); qqq.enqueue(3); System.out.println(qqq); qqq.enqueue(5); System.out.println(qqq); qqq.dequeue(); System.out.println(qqq); } }