This is an example using int variables, but the basic idea is that the value to be compared to the other values of the array is set to the first variable. Then as we find elements equal to the key, we increment a temporary count variable. If the temporary count variable is greater than the real count variable, then the real count variable is replaced by the temporary count variable. Once an unequal element is found, a new key value is set to the current element being iterated on and the temporary count variable is reset. This could be tinkered with, however, for example you can break out of the loop once the the temporary count reaches three. I'm not sure if this was what you were looking for, but enjoy.
int key = arr[0];
int tempCount = 0;
int realCount = 0;
for(int i = 1; i < arr.length; i++){
if(arr[i] == key){
tempCount++;
}
else{
key = arr[i];
tempCount = 0;
}
if(tempCount > realCount){
realCount = tempCount;
}
}
if(realCount >= 3){
boolean hasThreeOfTheSame = true;
//do stuff you want to do
}
EDIT: I now realize that the OP wanted a way to find if there were 3 of the same elements in an array despite the order. I misread this so my solution finds whether an array has 3 or more consecutive elements in a row (ex: [1, 1, 1, 2, 3] or [1, 2, 2, 2, 3]). I'm only going to keep this up because it may help someone out there.