How do I create a reference in a function that doesn't change the value of the function's parameter?
<p>I am new to java.
The question might not be that clear. Let me explain using code.
The code below is a function that prints out values in a linkedlist.
The first line of the function creates a reference to point to the same object that is pointed by the HeadNode reference. So any changes to currentNode will affect the object that HeadNode is pointing to. 
Now, inside the while loop, I am making the change of the currentNode, but I observe the linkedList didn't change after I exit the function. Why?</p>

<pre><code>static void PrintLinkedList(ListNode HeadNode)
    {
        ListNode currentNode = HeadNode;
        while(currentNode != null)
        {
            System.out.println(currentNode.getData());
            currentNode = currentNode.getNext();
        }
    }
</code></pre>

<p><strong>UPDATE:</strong></p>

<p>the reason of me bring this quesiton up is that when I implemented a function to reverse a linkedlist, my tempNode become null after the following code executed:</p>

<pre><code>static ListNode ReverseLinkedList(ListNode headNode)
    {
        ListNode headNodeTemp = headNode;
        headNodeTemp.setNext(null);
        ListNode tempNode = headNode.getNext(); //temp becomes null because headNode is changed. Why??
        ListNode currentNode = headNodeTemp;
        while(tempNode != null)
        {...
</code></pre>
