Question: If I have this code, how can I add elements to this list and print out the second to last node? public class Link private

If I have this code, how can I add elements to this list and print out the second to last node?

If I have this code, how can I add elements to this

public class Link private Link head; private Link tail; private Link curr; public void moveToEnd() curr = tail; public Link next() if (curr != tail) curr = curr.next(); return curr; public void prev() if(head.next() == curr) return; Link temp = head; while(temp.next() != curr) temp = temp.next(); curr = temp; public Link second() Y Link temp = this.curr; this.moveToEnd(); this.prev(); Link temp 2 = this.curr; this.curr = temp; return temp2; public static void main(String[] args) public class Link private Link head; private Link tail; private Link curr; public void moveToEnd() curr = tail; public Link next() if (curr != tail) curr = curr.next(); return curr; public void prev() if(head.next() == curr) return; Link temp = head; while(temp.next() != curr) temp = temp.next(); curr = temp; public Link second() Y Link temp = this.curr; this.moveToEnd(); this.prev(); Link temp 2 = this.curr; this.curr = temp; return temp2; public static void main(String[] args)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!