X976: Build Three Nodes

Using this class definition:

public class node<E> {
  //... instance variables
  public node(E d, node<E> n) {
    this.data = d;
    this.next = n;
  }
  public E getData() {return data; }
  public void setData(E d) {data = d; }
  public node<E> getNext() {return next; }
  public void setNext(node<E> n) {next = n; }
}

This is an extension of the previous problem, build2Nodes. You should build 3 nodes and store the value of a on the first, the value of b on the second, and the value of c on the third. The routine should return the pointer to the first node, the one with value of a stored in it.

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.