4-Linked Lists/07. Linked List Problems_/JavaLinkedListDataStructures/JavaLinkedListDataStructures/LinkedList.java
public int countNodes() {
        if (head  == null) {
           return  0;
        } else {
            Node<T> curr = head;
            int count = 0;
            while (curr != null) {
                curr = curr.getNext();
                count++;
            }
            return count;
        }
    }
/**
     * Count the number of nodes in the linked list.
     */
Count the number of nodes in the linked list.
Count the number of nodes in the linked list .
public int countNodes() {
        if (head  == null) {
           return  0;
        } else {
            Node<T> curr = head;
            int count = 0;
            while (curr != null) {
                curr = curr.getNext();
                count++;
            }
            return count;
        }
    }
public int countNodes ( ) { if ( head == null ) { return 0 ; } else { Node < T > curr = head ; int count = 0 ; while ( curr != null ) { curr = curr . getNext ( ) ; count ++ ; } return count ; } }
Count the number of nodes in the linked list.
Count the number of nodes in the linked list .