public class Queue { private Node first; public Queue() { first = null; } public boolean isEmpty() { if (first == null) return true; return false; } public T front(int n) { Node current = first; for (int i = 0; i < n; i++) { if (current == null) return null; current = current.next; } if (current == null) return null; return current.wert; } public void enqueue(T val) { Node neu = new Node(); neu.wert = val; if (first == null) { first = neu; } else { Node current = first; while (current.next != null) { current = current.next; } current.next = neu; } } public T dequeue() { T tmp = first.wert; first = first.next; return tmp; } public String toString(){ String result = ""; Node current = first; while (current != null) { result += current.wert + ", "; current = current.next; } return result; } }