Question: public class ItemNode { private String item; private ItemNode nextNodeRef; / / Reference to the next node public ItemNode ( ) { item =

public class ItemNode {
private String item;
private ItemNode nextNodeRef; // Reference to the next node
public ItemNode(){
item ="";
nextNodeRef = null;
}
// Constructor
public ItemNode(String itemInit){
this.item = itemInit;
this.nextNodeRef = null;
}
// Constructor
public ItemNode(String itemInit, ItemNode nextLoc){
this.item = itemInit;
this.nextNodeRef = nextLoc;
}
// Insert node after this node.
public void insertAfter(ItemNode nodeLoc){
ItemNode tmpNext;
tmpNext = this.nextNodeRef;
this.nextNodeRef = nodeLoc;
nodeLoc.nextNodeRef = tmpNext;
}
// TODO: Define insertAtEnd() method that inserts a node
// to the end of the linked list
// Get location pointed by nextNodeRef
public ItemNode getNext(){
return this.nextNodeRef;
}
public void printNodeData(){
System.out.println(this.item);
}
}

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 Programming Questions!