Class ListNode

java.lang.Object
  |
  +--ListNode

class ListNode
extends java.lang.Object

This is the a node for a singly-linked list, which is capable of holding an type of Object.

A ListNode consists of two data members:

Accessor and mutator methods are provided for all data members.


Field Summary
(package private)  java.lang.Object data
           
(package private)  ListNode next
           
 
Constructor Summary
ListNode()
          Creates a completely blank ListNode
ListNode(java.lang.Object data)
          Creates a new ListNode containing the specified data type.
ListNode(java.lang.Object data, ListNode next)
          Creates a new ListNode object containing specified data and next references.
 
Method Summary
 java.lang.Object getData()
          Returns this ListNode's data
 ListNode getNext()
          Returns the next ListNode in the chain.
 void setData(java.lang.Object obj)
          Sets this ListNode's data to be the specified object
 void setNext(ListNode new_next)
          Sets this ListNode's next reference to be the specified ListNode
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

data

java.lang.Object data

next

ListNode next
Constructor Detail

ListNode

public ListNode()
Creates a completely blank ListNode

ListNode

public ListNode(java.lang.Object data)
Creates a new ListNode containing the specified data type. This ListNode's next reference is set to null

ListNode

public ListNode(java.lang.Object data,
                ListNode next)
Creates a new ListNode object containing specified data and next references. Note that if there is no next reference, null should be passed
Parameters:
data - the data item this node is keeping track of
next - the next ListNode in the chain. If there is no next node, should be passed
Method Detail

getData

public java.lang.Object getData()
Returns this ListNode's data

getNext

public ListNode getNext()
Returns the next ListNode in the chain. Note that ifnull is returned, there are no more items in the chain.

setData

public void setData(java.lang.Object obj)
Sets this ListNode's data to be the specified object

setNext

public void setNext(ListNode new_next)
Sets this ListNode's next reference to be the specified ListNode