Android examples for java.lang:array
binary Search a long type array
//package com.java2s; public class Main { public static int binarySearch(long[] srcArray, long des) { int low = 0; int high = srcArray.length - 1; while (low <= high) { int middle = (low + high) / 2; if (des == srcArray[middle]) { return middle; } else if (des < srcArray[middle]) { high = middle - 1;// ww w .j a v a2 s.c o m } else { low = middle + 1; } } return -1; } }