forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
32 lines (24 loc) · 639 Bytes
/
Node.java
File metadata and controls
32 lines (24 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.thealgorithms.datastructures;
import java.util.ArrayList;
import java.util.List;
public class Node<T> {
private final T value;
private final List<Node<T>> children;
public Node(final T value) {
this.value = value;
this.children = new ArrayList<>();
}
public Node(final T value, final List<Node<T>> children) {
this.value = value;
this.children = children;
}
public T getValue() {
return value;
}
public void addChild(Node<T> child) {
children.add(child);
}
public List<Node<T>> getChildren() {
return children;
}
}