Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        // initializing sorted char array
        char charArr[] = { 'a', 'c', 'd', 'e', 'f' };

        // value to search
        char searchVal = 'e';

        int retVal = Arrays.binarySearch(charArr, searchVal);

        System.out.println("The index of e is : " + retVal);
    }
}