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