Class Node

java.lang.Object
  |
  +--Node

public class Node
extends Object

A singly-linked Node. Contains an Object and a reference to the next Node.

Version:
17 Feb 2005
Author:
Zach Tomaszewski

Constructor Summary
Node(Object contents)
          Creates a new Node with no links.
Node(Object contents, Node next)
          Create a new node with the given contents and link to another (next) node.
 
Method Summary
 Node getNext()
          Returns the next node in a list after this node.
 Object getValue()
          Returns this node's contents.
 void setNext(Node next)
          Set this node's next reference to the given node.
 void setValue(Object value)
          Sets this node to contain the given value
 String toString()
          Returns a String representation of this node, including the value contained, as well as the value of the next node (if any).
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(Object contents)
Creates a new Node with no links.

Node

public Node(Object contents,
            Node next)
Create a new node with the given contents and link to another (next) node.
Method Detail

setValue

public void setValue(Object value)
Sets this node to contain the given value
Parameters:
value - The new contents of this node.

getValue

public Object getValue()
Returns this node's contents.

getNext

public Node getNext()
Returns the next node in a list after this node.

setNext

public void setNext(Node next)
Set this node's next reference to the given node.
Parameters:
next - The node this node should point to as next in a list.

toString

public String toString()
Returns a String representation of this node, including the value contained, as well as the value of the next node (if any). Format: [value --> (next value)]
Overrides:
toString in class Object