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 short array
        short shortArr[] = { 1, 2, 15, 52, 110 };

        // value to search
        short searchVal = 15;

        // entering range of index
        int retVal = Arrays.binarySearch(shortArr, 3, 4, searchVal);

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