public static int[] getNextArray(char[] p){
        int len = p.length;
        int[] next = new int[len];
        //初始值-1相当于一个标志
        next[0] = -1;

        int k = -1;
        int j = 0;

        while (j < len-1){
            //k==-1 条件作为初始的入口
            if (k == -1 || p[k] == p[j]){
                next[j+1]=k+1;
                k++;
                j++;
               //next[j]=k;
            }else {
                k = next[k];
            }
        }
        return next;
    }