- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathNode.java
32 lines (24 loc) · 639 Bytes
/
Node.java
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
packagecom.thealgorithms.datastructures;
importjava.util.ArrayList;
importjava.util.List;
publicclassNode<T> {
privatefinalTvalue;
privatefinalList<Node<T>> children;
publicNode(finalTvalue) {
this.value = value;
this.children = newArrayList<>();
}
publicNode(finalTvalue, finalList<Node<T>> children) {
this.value = value;
this.children = children;
}
publicTgetValue() {
returnvalue;
}
publicvoidaddChild(Node<T> child) {
children.add(child);
}
publicList<Node<T>> getChildren() {
returnchildren;
}
}