#Linked list question
1 messages · Page 1 of 1 (latest)
We haven't assigned to first or to any field in a node connected to the list.
We've discarded the new node that t was pointing to, by assigning t to a node in the list (the one after the node originally referred to by x).
We've then move x along one position by assigning to match t.
But the list hasn't changed. We never used the new node, and x isn't part of the list, it's just a reference into it.
this?
we pointed the x to t which should delete the res of the nodes
(im not sure, need to revise this thing again)
x is just a variable, not the owner of the list. You can have as many references into the list as you like, it doesn't change the list itself.
String s = "example";
String t = s; // this doesn't change 's' at all. They both now refer to the same String instance.
yea ig it'll be "does nothing to the list"
Oh ok so if the node that x is pointing to let's say is "n" then-:
n.next = t
would do what I did?
yes