@Override public String toString() { String result = "MyLinkedList{"; LLNode<E> probe = head; for (int i = 0; i < this.size; i++) { result += probe + " "; probe = probe.getNext(); } result += '}'; return result; }
// Return the next node based on the referenceNode private LLNode<E> getNext(LLNode<E> referenceNode) { if (referenceNode == tail) { throw new BoundaryViolationException("Reference cannot be equal to tail"); } return referenceNode.getNext(); }