Java tutorial
import java.util.Arrays; public class Main { public static void main(String[] args) { byte bArray[] = { 1, 2, 4, 5 }; Arrays.sort(bArray); byte searchValue = 2; int intResult = Arrays.binarySearch(bArray, searchValue); System.out.println("Result of binary search of 2 is : " + intResult); searchValue = 7; intResult = Arrays.binarySearch(bArray, searchValue); System.out.println("Result of binary search of 3 is : " + intResult); } }