I'm trying to initialize a class like this, but I get NullPointerException. What is wrong with it?
public class TreeNode {
private char letter;
private TreeNode[] link;
public void set_letter(char letter) {
this.letter = letter;
}
public char get_letter() {
return letter;
}
public TreeNode(char c){
// Initialize the node
set_letter(c);
// Default value for links is NULL
for(int i=0; i<10; i++){
link[i] = null;
}
}
public static void main(String[] args) throws Exception {
TreeNode tn = new TreeNode((char)97);
}
}