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 double array
        double doubleArr[] = { 5.4, 5.5, 9.2, 9.3, 35.4 };

        // value search
        double searchVal = 5.4;

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

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