Class Node<E>
- java.lang.Object
-
- Node<E>
-
public class Node<E> extends java.lang.Object
A simple class to represent a linked list node.- Version:
- 1.1
- Author:
- Rui Meireles
-
-
Constructor Summary
Constructors Constructor Description Node(E value)
Constructs a new object with the value passed in as an argument and a null next reference.Node(E value, Node<E> next)
Constructs a new object with the value passed in as an argument and a next reference to a node passed as an argument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Node<E>
getNext()
Returns the next reference stored at this node, which represents the next node in the linked list.E
getValue()
Returns the value stored at this node.void
setNext(Node<E> next)
Sets this node's next reference, which represents the next node in the linked list, to the value passed as an argument.void
setValue(E value)
Sets the value of this node to the value passed as an argument.
-
-
-
Constructor Detail
-
Node
public Node(E value, Node<E> next)
Constructs a new object with the value passed in as an argument and a next reference to a node passed as an argument.- Parameters:
value
- the value to store in the node
-
Node
public Node(E value)
Constructs a new object with the value passed in as an argument and a null next reference.- Parameters:
value
- the value to store in the node
-
-
Method Detail
-
getValue
public E getValue()
Returns the value stored at this node.- Returns:
- the value stored at this node
-
setValue
public void setValue(E value)
Sets the value of this node to the value passed as an argument.- Parameters:
value
- value to be stored
-
getNext
public Node<E> getNext()
Returns the next reference stored at this node, which represents the next node in the linked list.- Returns:
- the next reference stored at this node
-
-