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)); } }