public class IntNode
extends java.lang.Object
Constructor and Description |
---|
IntNode(int initialData,
IntNode initialLink)
Initialize a node with a specified initial data and link to the next
node.
|
Modifier and Type | Method and Description |
---|---|
void |
addNodeAfter(int element)
Modification method that adds a new node to the list after this node.
|
int |
getData()
Accessor method to get the data from this node.
|
IntNode |
getLink()
Accessor method to get a reference to the next node after this node.
|
static int |
listLength(IntNode head)
Accessor method that returns the number of nodes in the list provided.
|
void |
removeNodeAfter()
Modification method that removes the node after this one.
|
void |
setData(int newData)
Modification method to set the data in this node.
|
void |
setLink(IntNode newLink)
Modification method to set the link to the next node after this node.
|
static java.lang.String |
toString(IntNode head)
Accessor method that returns a string representation of a supplied list.
|
public IntNode(int initialData, IntNode initialLink)
initialData
- the initial data of this new nodeinitialLink
- a reference to the node after this new node--this reference may be
null to indicate that there is no node after this new node.public int getData()
-
- nonepublic IntNode getLink()
-
- nonepublic void setData(int newData)
newData
- the new data to place in this nodepublic void setLink(IntNode newLink)
newLink
- a reference to the node that should appear after this node in the
linked list (or the null reference if there is no node after this node)public static int listLength(IntNode head)
head
- a reference to the head node of a list.public void addNodeAfter(int element)
element
- public void removeNodeAfter()
public static java.lang.String toString(IntNode head)
head
-