title: Recursion with linked lists for Java student
body: <p>Please be gentle on me here... I'm learning and could use some assistance. I'm trying to wrap my head around the linked list method below. I thought I understood how recursion worked, but I'm missing something here. Could someone help me understand the logic, and the complete call stack for this method? I can't figure out how the items are added up... I'm afraid some degree of detail is needed here. I've looked elsewhere for help but other examples do not seem to be helping.</p>
  
  <pre><code>/**
  * Compute the sum of all the integers in a linked list of integers. 
  * @param head a pointer to the first node in the linked list
  */
    public static int addItemsInList( IntNode head ) { 
      if ( head == null ) {
          // Base case: The list is empty, so the sum is zero. 
        return 0;
      } else {
            // Recursive case: The list is non-empty. Find the sum of
            // the tail list, and add that to the item in the head node.
            // (Note that this case could be written simply as
            //return head.item + addItemsInList( head.next );)
        int listsum = head.item;
        int tailsum = addItemsInList( head.next ); 
        listsum = listsum + tailsum;
        return listsum;
     }
  }
  </code></pre>