I don't grasp the KMP algorithm

I’m having trouble comprehending the KMP algorithm. I understand prefix-suffix and have written code to calculate the prefix-suffix table:

 private int[] calculatePrefSuffArray(String pattern) {
    char patternArray[] = pattern.toCharArray();
    int tab[] = new int[pattern.length()];
    tab[0] = 0;
    int t = tab[0];
    for (int i = 1; i < pattern.length(); i++) { // t = tab[i-1]
        while(t >0 && patternArray[i] != patternArray[t] ) {
            t = tab[t-1];
        if(patternArray[i] == patternArray[t]) t++;
        tab[i] = t;
    return tab;

But I’m not sure how to utilize it in KMP. Could you please explain it to me?
According to the explanation of this technique provided here, this -1 will be used to determine the start of the array, and it may be utilized in further uncommon instances and is used within the last otherwise portion. I’m concerned about my code; is it correct? To work with my code, I had to check the start of the array myself. However, I like this algorithm.

Try this article KMP Algorithm Explained In Plain English – W3 Spot. It explains how KMP search works with solid examples.