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 float array
        float floatArr[] = { 5.2f, 5.3f, 5.9f, 6.3f };

        // value to search
        float searchVal = 6.3f;

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

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