Class ListNode<T>

java.lang.Object
com.amritpandey23.dsalibrary.linkedlist.ListNode<T>
Type Parameters:
T - the type of the value stored in the list node

public class ListNode<T> extends Object
Represents a node in a singly linked list, containing a generic value and a reference to the next node.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Pointer to the next node in the list.
    The value stored in this list node.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ListNode(T val)
    Constructs a list node with a specified value and no reference to the next node.
    ListNode(T val, ListNode<T> next)
    Constructs a list node with a specified value and a reference to the next node.
  • Method Summary

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • val

      public T val
      The value stored in this list node.
    • next

      public ListNode<T> next
      Pointer to the next node in the list.
  • Constructor Details

    • ListNode

      public ListNode(T val)
      Constructs a list node with a specified value and no reference to the next node.
      Parameters:
      val - the value to be stored in this list node
    • ListNode

      public ListNode(T val, ListNode<T> next)
      Constructs a list node with a specified value and a reference to the next node.
      Parameters:
      val - the value to be stored in this list node
      next - the next node in the list