current
is a reference to the current position in your linked list. After the while loop, current
refers to the second to last item. When you say current.next = null
, you make the current object's next
become null
. That makes the current object the last object.
When you say current = null
, you are just setting your local reference variable to null
. In other words, it no longer refers to your list. It refers to null
.