0

```
public class Sorting
{
public static void main(String[] args)
{
int j=10;
int[] arr=new int[10];
for(int i=0;i<arr.length;i++)
{
arr[i]=j;
j+=10;
}
int num=Integer.parseInt(args[0]);
bsearch(arr,0,10,num);
}
static void bsearch(int[] arr2,int first,int last,int key)
{
while(first<=last)
{
int mid=(first+last)/2;
if(key==arr2[mid])
{
System.out.println("Found the key");
}
else if(key<arr2[mid])
{
last=mid-1;
}
else if(key>arr2[mid])
{
first=mid+1;
}
else
{
System.out.println("Did not find the key");
}
}
}
}
```

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting