0% found this document useful (0 votes)
4 views2 pages

Generic Node Class Implementation

The document defines a Node class that represents a node in a linked list. The Node class has fields to store a value and a reference to the next node. It also contains getter, setter, and other methods to access and manipulate the value and next fields.

Uploaded by

Elai Grisaru
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Generic Node Class Implementation

The document defines a Node class that represents a node in a linked list. The Node class has fields to store a value and a reference to the next node. It also contains getter, setter, and other methods to access and manipulate the value and next fields.

Uploaded by

Elai Grisaru
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

/* The class IntNode **/

public class Node<T>

private T value; // IntNode value

private Node<T> next; // next IntNode

/* Constructor - returns a IntNode with "value" as value and without successesor IntNode
**/

public Node(T value)

[Link] = value;

[Link] = null;

/* Constructor - returns a IntNode with "value" as value and its successesor is "next" **/

public Node(T value, Node<T> next)

[Link] = value;

[Link] = next;

/* Returns the IntNode "value" **/

public T getValue()

return [Link];

/* Returns the IntNode "next" IntNode **/

public Node<T> getNext()

{
return [Link];

/* Return if the current IntNode has successor **/

public boolean hasNext()

return ([Link] != null);

/* set the value attribute to be "value" **/

public void setValue(T value)

[Link] = value;

/* set the next attribute to be "next" **/

public void setNext(Node<T> next)

[Link] = next;

/* Returns a String that describes the IntNode (and its' successesors **/

public String toString()

return value + " --> " + next;

You might also like