Binary Search in java
import
java.util.Arrays; import
java.util.Scanner; public class Arrays1 {
System.out.println(b+" found at location "+v);
public static void main(String[] args) {
int
i,n;
Scanner na
= new Scanner(System.in);
System.out.println("enter
No. of element");
n=na.nextInt();
System.out.println("enter No. of array");
int number[]= new int[n];
for
(i=0;i<n;i++){
number [i]=na.nextInt();
}
System.out.println("enter ther search value:- ");
int b=na.nextInt();
System.out.println("enter ther search value:- ");
int b=na.nextInt();
int v = Arrays.binarySearch(number,5);
System.out.println(v);
}
}
binarySearch() is a method .
binarySearch() is a method .
0 comments:
Post a Comment