Performing Binary Search on Java char Array Example
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
char charArray[] = { 'a', 'b', 'd', 'e' };
Arrays.sort(charArray);
char searchValue = 'b';
System.out.println(Arrays.binarySearch(charArray, searchValue));
searchValue = 'z';
System.out.println(Arrays.binarySearch(charArray, searchValue));
}
}
Related examples in the same category