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';

        // entering the range of index
        int retVal = Arrays.binarySearch(charArr, 1, 5, searchVal);

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