Java Arrays 二分查找字符 Java Arrays binarySearch方法 Java Arrays 二分查找字符索引 Java Arrays 二分查找字符 package com.codingdict; import java.util.Arrays; public class ArrayDemo { public static void main(String[] args) { // initializing unsorted char array char charArr[] = {'a', 'c', 'b', 'e','d'}; // sorting array Arrays.sort(charArr); // let us print all the elements available in list System.out.println("The sorted char array is:"); for (char number : charArr) { System.out.println("Number = " + number); } // entering the value to be searched char searchVal = 'e'; int retVal = Arrays.binarySearch(charArr, searchVal); System.out.println("The index of e is : " + retVal); } } Java Arrays binarySearch方法 Java Arrays 二分查找字符索引