educative.io

Why if we don't use list keyword, does this is still work

I can’t understand even if we don’t use list keyword

compare.nextNode = compare.nextNode.nextNode;

it works for list linked list.


Type your question above this line.

Course: https://www.educative.io/collection/5642554087309312/5724822843686912
Lesson: https://www.educative.io/collection/page/5642554087309312/5724822843686912/5713391385575424

Hey @Azizbek_Khushvakov!
The head node of the list is saved in the compare pointer.

   SinglyLinkedList<T>.Node current = list.headNode; 
    compare = current;

So we don’t need the list keyword here.

1 Like