Java examples for Language Basics:char
Performing Binary Search on Java char Array
import java.util.Arrays; public class Main { public static void main(String[] args) { char charArray[] = {'a','b','d','e'}; Arrays.sort(charArray);// w w w. j a va 2 s . co m char searchValue = 'b'; int intResult = Arrays.binarySearch(charArray,searchValue); System.out.println("Result of binary search of 'b' is : " + intResult); searchValue = 'c'; intResult = Arrays.binarySearch(charArray,searchValue); System.out.println("Result of binary search of 'c' is : " + intResult); } }