// Textbook fragment 05.15 public void enqueue(E elem) { Node node = new Node(); node.setElement(elem); node.setNext(null); // node will be new tail node if (size == 0) head = node; // special case of a previously empty queue else tail.setNext(node); // add node at the tail of the list tail = node; // update the reference to the tail node size++; }