When creating my own singly linked list class I noticed that the push and pop functions seems to work as expected. Although in the `pop_back()` method I set `headTmp = null` to indicate that this is no longer required. Also, can this potentially screw up the assignment to tmp since it is assigned to headTmp.data? Is this assignment a copy or a reference assignment to headTmp.data? I am unsure if Java does copies outside of arguments to functions. 

In C++ the assignment would be a copy and then I would have a pointer and just delete the headTmp item. Do I need to have `headTmp = null` in this code or does this not help anything or potentially hurt the assignment of the data and is just setting the `prev.next = null` enough and will the GC will handle this clean up? Should I think about garbage collection similar to a shared pointer in C++ where reference counting is used such that when nothing is pointing to this object it gets cleaned up? I am used to cleaning up my own garbage

```
package dynamiclist;

public class LinkedList<T>
{
    public T pop_back()
    {
        Node<T> prev = null;
        Node<T> headTmp = head;

        while ( headTmp.next != null)
        {
            prev = headTmp;
            headTmp  = headTmp.next;
        }

        T tmp = headTmp.data;
        headTmp = null;  // does this help in GC at all? Does it effect previous assignment of tmp?

        prev.next = null;
        return tmp;
    }

    public void push_back(T t)
    {
        if (head == null)
        {
            head = new Node<T>(t);
            return;
        }

        Node<T> headTmp = head;
        while (headTmp.next != null)
        {
            headTmp= headTmp.next;
        }

        headTmp.next = new Node<T>(t);
        headTmp.next.next=null;
    }

    public void printList()
    {
        Node<T> headTmp = head;
        while ( headTmp!=null)
        {
            headTmp.printNode();
            headTmp = headTmp.next;
        }
        System.out.println();
    }

    private Node<T> head;
}

```