/** * Adds the given node at the end of the list. * * @param newNode the node to be added */ public void addNode(ListNode newNode) { ListNode currentNode = this.getHeadNode(); while (currentNode.getNextNode() != null) { currentNode = currentNode.getNextNode(); } currentNode.setNextNode(newNode); }
/** This method iterates through the list and prints all values stored by the list. */ public void printAllNodes() { ListNode currentNode = this.getHeadNode(); while (currentNode != null) { System.out.println(currentNode.getNodeValue()); currentNode = currentNode.getNextNode(); } }