#How does the loop know where the next node is, if the current iteration sets pointers to null

12 messages · Page 1 of 1 (latest)

woven yoke
#

this is with reference to clearing a linked list...

once trav.next is set to null in the while loop, how does it know which node to operate on during its next loop iteration?

My understanding is that trav.next = null sets the pointer to null so it shouldn't know where the next node is

tardy arrowBOT
#

This post has been reserved for your question.

Hey @woven yoke! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

woven yoke
#

please ping me when answering, thank you

tardy arrowBOT
# woven yoke please ping me when answering, thank you

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

lean nacelle
woven yoke
lean nacelle
#

Node<T> next = trav.next

#

The first step in the loop is to grab the reference in to the next variable

woven yoke
#

oh, that makes sense now. Silly me

#

thank you!

tardy arrowBOT
# woven yoke thank you!

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.