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) {
        byte bArray[] = { 1, 2, 4, 5 };
        Arrays.sort(bArray);

        byte searchValue = 2;

        int intResult = Arrays.binarySearch(bArray, searchValue);
        System.out.println("Result of binary search of 2 is : " + intResult);

        searchValue = 7;
        intResult = Arrays.binarySearch(bArray, searchValue);
        System.out.println("Result of binary search of 3 is : " + intResult);
    }
}