Question: X 9 7 5 : Build Two Nodes Using this class definition: 1 public class node { 2 / / . . . instance variables
X: Build Two Nodes
Using this class definition:
public class node
instance variables
public nodeE d node n
this.data d;
this.next n;
public E getDatareturn data;
public void setDataE ddata d;
public node getNextreturn next;
public void setNextnode nnext n;
Complete the method buildNodes that creates two objects of type node, and places the values of the a and b parameters in these nodes. The first node a should have its next field point to the second node created b The method should return the head of the list created, that is the pointer to the node with the value in a
Your Answer:
public node buildNodesE a E b
Using this class definition:
public class node
instance variables
public nodeE d node n
this.data d;
this.next n;
public E getDatareturn data;
public void setDataE ddata d;
public node getNextreturn next;
public void setNextnode nnext n;
Complete the method createNewNode that returns a new node using the constructor above.
Your Answer:
public node createNewNodeE a
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
