让 head 指向以下链表的第一个元素 1->2->3->Null
链表的每个元素都是具有属性的 Node() : val 和 next
什么时候 :
curr=head
head=head.next
curr.next.val= 1000
#here head.val outputs 1000 : We changed the value of the 2nd node
但当 :
curr=head
head=head.next
curr.next= Node(1000)
#here head.val outputs 2, it seems that the change
#we made in the previous line didn't
#affect the node but rather created a new 'route'.
有人可以解释为什么在第一种情况下我们正在修改节点值 wrt head 而在第二种情况下我们没有?
谢谢