提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
在Java char数组上执行二进制搜索
import java.util.Arrays;// 来 自 时代Java - nowjava.com public class Main { public static void main(String[] args) { char charArray[] = {'a','b','d','e'}; Arrays.sort(charArray); char searchValue = 'b'; int intResult = Arrays.binarySearch(charArray,searchValue); System.out.println("Result of binary search of 'b' is : " + intResult); searchValue = 'c'; intResult =