@@ -0,0 +1,863 @@
+package com.linbo.algs.searchings;%0A%0Aimport java.util.Arrays;%0A%0A/**%0A * Created by @linbojin on 1/2/17.%0A *  This class provides a static method for binary%0A *  searching for an integer in a sorted array of integers.%0A */%0Apublic class BinarySearch %7B%0A%0A  private BinarySearch() %7B %7D%0A%0A  public static int indexOf(int%5B%5D a, int key) %7B%0A    int lo = 0;%0A    int hi = a.length - 1;%0A    while (lo %3C= hi) %7B%0A      int mid = (lo + hi) / 2;%0A      if (key %3C a%5Bmid%5D) hi = mid - 1;%0A      else if (key %3E a%5Bmid%5D) lo = mid + 1;%0A      else return mid;%0A    %7D%0A    return -1;%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A%0A    int%5B%5D arr = %7B3, 23, 89, 12, 5%7D;%0A    Arrays.sort(arr);%0A    // 3, 5, 12, 23, 89%0A%0A    System.out.println(BinarySearch.indexOf(arr, 5)); // 1%0A    System.out.println(BinarySearch.indexOf(arr, 89)); // 4%0A    System.out.println(BinarySearch.indexOf(arr, 6)); // -1%0A  %7D%0A%0A%7D%0A

add binary search algorithm implementation