Error puntero nulo

Hola buenas, esoy haciendo este proyecto pero me da fallo Exception in thread "main" java.lang.NullPointerException. La linea es esta:
if (insertNode((char)n[index],index, root) != 0) { esta casi al final del codigo donde empieza el for, pero no consigo ver el fallo. Tu lo ves? Gracias
import java.io.*;
class NInternal {
    Node[] next;
}
class NList {
    String w;
    NList[] next;
}
class Node {
    char c;
    NInternal[] i = new NInternal[10];
    NList e = new NList();
}
public class Main {
    static public char getChar() throws IOException {
        char c = (char) System.in.read();
        input();
        return c;
    }
    static public void input() throws IOException {
        while ((char) System.in.read() != '\n');
    }
    static public int initNode(Node n, char l) throws IOException {
        // Inicializar el nodo a insertar
        n.e = null;
        n.c = l;
        return 0;
    }
    static public int insertNode(char l, int r, Node root) throws IOException {
        // Inicializar el nodo a insertar
        Node newNode = new Node();
        if (initNode(newNode, l) != 0) {
            System.out.println("Fallo al inicializar el Nodo\n");
        } else {
            // En caso de que sea el primer nodo a insertar.
            if (root == null) {
                System.out.println("Se va a insertar el nodo raiz \n");
                root = newNode;
            } else { // Cualquier otro nodo despues del raiz.
            }
        }
        return r;
    }
    public static void main(String[] args) throws IOException {
        char res;
        Node root = null;
        String s = "";
        InputStreamReader input = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(input);
        do {
            System.out.println("Inserte una palabra y pulse ENTER");
            try {
                s = reader.readLine();
                s = s.toLowerCase();
            } catch (Exception e) {
            }
            System.out.println("Escribiste: " + s + "\n");
            int n[] = null;
           // n = new int[27];
            int tam = s.length();
            int index = 0;
            int max = 0;
            char l;
        char letras[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','ñ','o','p','q','r','s','t','u','v','w','x','y','z'};
        for (int i=0; i<letras.length; i++){
            max= contar(s,letras);
            if (max>0) {
                    System.out.println("El texto contiene " + max + " veces la letra " + letras);
                }
            if (max>index){
                l=letras;
                //c=m;
                max=index; // el mayor es m
            }
        }
                    System.out.println("La letra mas alta del alfabeto  es la "+max+"");
            for (index = 0; index <= max; index++) {
                if (insertNode((char)n[index],index, root) != 0) {
                    System.out.println("Se inserto el caracter " + index + " con: " + n[index] + " repeticiones");
                }
                if (n[index] != 0) {
                    System.out.println("Cantidad de letras " + index + " en la frase es:" + n[index]);
                }
            }
            //exter[mayor] = mayor;
            System.out.println("Quiere insertar otra palabra? S/N");
            res = getChar();
        } while (res !=...

Añade tu respuesta

Haz clic para o