The array is already sorted from smallest to largest. Return the position of the target, or -1 when it is absent. Halve the range each time rather than checking every item.
int search(int[] sorted, int target)
Examples
There are also 4 hidden tests you can't see. Solve the problem, not the examples.