X341: lastNodeRef1

Consider the following class definition:

class Link{
  public Object data;
  public Link next;
}

In the method below, you will receive a reference to the head of a linked chain p. Write a method to return a reference to the last link in the chain. If p is null, be sure to return null.

Initial Setup Final Configuration

Your Answer:

Reset
Visualize

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.