Package model.estrutura
Class Data
java.lang.Object
model.estrutura.Data
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetData()
Returns the string data stored in this node.Returns the next data node in the sequence.void
Sets the string data for this node.void
setNextData
(Data nextData) Sets the reference to the next data node in the sequence.toString()
Returns a string representation of this data node.
-
Field Details
-
Constructor Details
-
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
Returns the string data stored in this node.- Returns:
- the string data stored in this node
-
setData
Sets the string data for this node.- Parameters:
data
- the new string data to be stored in this node
-
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
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
Returns a string representation of this data node. The returned string is the data value stored in this node.
-