I’m trying to figure out how to write a method that would modify the last node in a linkedlist and change it from null to the first node when passed the first pointer from the linked list.
I tried this which turned into a error:
public void blah()
{
Node p = first;
while (p != null)
{
p = p.link;
}
p.x = p.first;
}
Try this:
Be aware that this will create a circular list, that’s what you intend, right? Also, I’m assuming that
firstis an attribute of the class whereblah()resides.