Class Tree.TreeNode<T>
java.lang.Object
util.collection.Tree.TreeNode<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(Tree.TreeNode<T> child) Adds a child node to this node.boolean
isLeaf()
Checks if this node is a leaf (has no children).
-
Field Details
-
value
The value stored in this tree node. It can be of any generic type. -
children
The list of child nodes of this node. Each element in the list is aTree.TreeNode
representing a subtree. Initially, the list is empty.
-
-
Constructor Details
-
TreeNode
Constructs a tree node with the specified value.- Parameters:
value
- the value to store in the node
-
-
Method Details
-
addChild
Adds a child node to this node.- Parameters:
child
- the child node to add
-
isLeaf
public boolean isLeaf()Checks if this node is a leaf (has no children).- Returns:
- true if the node is a leaf, false otherwise
-