i am working with linked list,and I have one possibly stupid question.I have class Node for linked list which contains attribute Node as next element,and I have this line:
Node current=head;
while(current!=null)
current=current.next;
I don't understand why head doesn't also change,but only current?And why does it change only if I do current.next=current.next.next
,how can that reflect anyhow on head?I understand that with current=current.next
we iterate through current(head),and it changes current,but why doesn't it change head also?Thank you in advance!