In this method I keep getting a return value of One even after I add more nodes
问题 Got a quick question, this is part of a linked list. It determines what the size of the list is, it doesnt work very well at the moment because it keeps returning a 1 even after I add more nodes. public int size(){ ListNode currentNode = null; ListNode previousNode = null; int numberOfNodes = 0; if (head == null) return 0; previousNode = head; currentNode = head.next; numberOfNodes++; while (currentNode != null){ previousNode = currentNode; currentNode = currentNode.next; numberOfNodes++; }