public class Node {
int value;
List<Node> childNodes;
Node(int x) {
value = x;
}
}
Above is the definition of the tree node and we have a tree.
Node root = new Node(0);
Node n1 = new Node(1);
root.childNodes.add(n1); Line 1
This is how I construct the initial tree structure in main, however, I got a nunllpointerexception in line 1. Anybody knows the reason?