Try
while(min<=max);
You might be missing the cases where min and max coincide.
Update:
Yup! I checked it. I ran your program against
int[] array = {19,17,2,15,6,13,12,7,16,3,22};
for all values and it works as expected if you make that correction.