Here you can find the source of binarySearch(char[] arr, int key)
static int binarySearch(char[] arr, int key)
//package com.java2s; //License from project: Open Source License public class Main { static int binarySearch(char[] arr, int key) { int length = arr.length; if (key <= arr[length - 1]) { int l = 0; int r = length - 1; while (l <= r) { int mid = (l + r) >>> 1; char val = arr[mid]; if (key > val) { l = mid + 1;/*from ww w . j a va 2s . co m*/ } else if (key < val) { r = mid - 1; } else { return mid; } } } return 0xffff; } }