Class Data

java.lang.Object
model.estrutura.Data

public class Data extends Object
Represents a data node in a linked list structure. Each node contains a string data value and a reference to the next data node.

This class is designed to be used as a building block for linked list implementations that store string data.

Since:
2024
  • Field Details

  • Constructor Details

    • Data

      public Data(String data)
      Constructs a new Data node with the specified string data. The nextData reference is initialized to null.
      Parameters:
      data - the string data to be stored in this node
  • Method Details

    • getData

      public String getData()
      Returns the string data stored in this node.
      Returns:
      the string data stored in this node
    • setData

      public void setData(String data)
      Sets the string data for this node.
      Parameters:
      data - the new string data to be stored in this node
    • getNextData

      public Data getNextData()
      Returns the next data node in the sequence. If this node is the last one in the list, returns null.
      Returns:
      the next data node in the sequence, or null if this is the last node
    • setNextData

      public void setNextData(Data nextData)
      Sets the reference to the next data node in the sequence. Use null to indicate that this node is the last one in the list.
      Parameters:
      nextData - the next data node in the sequence, or null to make this the last node
    • toString

      public String toString()
      Returns a string representation of this data node. The returned string is the data value stored in this node.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this data node