Performing Binary Search on Java short Array
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
short shortArray[] = { 1, 2, 4, 5 };
Arrays.sort(shortArray);
short searchValue = 2;
System.out.println(Arrays.binarySearch(shortArray, searchValue));
searchValue = 3;
System.out.println(Arrays.binarySearch(shortArray, searchValue));
}
}
Related examples in the same category