I have a problem with an algoritm (JAVA) that check consecutive elements in a list.

For example:
list: [1,2,3,3,4,5,3,3] ==> I want: how many times number 3 is consecutive twice? Result: 2

This is my code but i haven't a good result...

public class CheckConsecutiveElements {

```
/**
 * Returns the number of groups containing "numOfOccs" occurrences of element "elem" passed as argument.
 *
 * @param  numOfOccs     the exact number of consecutive occurrences
 * @param  elem            the element to search occurrences for
 * @param  whereToFind   the array to search for repetitions
 * @return number of groups with "numOfOccs" consecutive repetitions of element "elem"
 */

public int nGroup(int numOfOccs,int elem, int[] whereToFind) {
    int contador=0;
    if (numOfOccs==0 || whereToFind==null) //case null
        return contador;
    for (int i=0; i<whereToFind.length; i++){
        if(whereToFind[i]!=elem)  //if "elem" doesn't appear on the array
            return contador;
        for (int j=1; j<whereToFind.length; j++){
            if(whereToFind[i]==elem && (whereToFind[i]==whereToFind[j]))
                contador++;
        }

    }

    return contador;
}

```

}

I have this output now on console:

```
*** Error: check_consecutive_elements returns 6 groups
instead of 2 when counting groups of 2 repetitions of element 4 in the array
 [4,4,4]

```

Examples:

nGroup(0, 2, {1,2,2,2,3,2}) ==> 0

nGroup(1, 2, {1,2,2,2,3,2}) ==> 4

nGroup(2, 2, {1,2,2,2,3,2}) ==> 2

nGroup(3, 2, {1,2,2,2,3,2}) ==> 1

nGroup(4, 2, {1,2,2,2,3,2}) ==> 0

Can you help me? thanks...