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 array
        Object arr[] = { 1, 2, 22, 69, 111, 222 };

        // value to search
        int searchVal = 22;

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

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