Arrays.binarySearch() finds the index of a value inside a sorted array:
int[] sorted = {3, 17, 42, 56, 89};
int idx = Arrays.binarySearch(sorted, 42);
System.out.println(idx); // 2
The array must be sorted before you call this method. If it is not sorted, the result is unpredictable. If the value is not found, the method returns a negative number.
Why not just loop through and check each element? A loop checks every element one by one, which takes time proportional to the array's length. Binary search cuts the search space in half on each step, which is much faster on large arrays. You will study this algorithm in depth when you reach data structures and algorithms.