I\'m trying to write a simple method to count all the nodes in the linked list. I know there are 7 items in the linked list, but it is returning just 6 of them.
Her
I figured it out.
for (ListNode n = head; n != null; n = n.next)
n.next !=null was the error.