WAP to search a value in a array using binary search.Value should be accepted from the user

17/10/2013 21:30
import java.io.*;
public class binarysearch
{
public static void main(String args[])throws IOException
{
System.out.println("enter the element");
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(ir);
int[]a={12,43,67,77,95,100,105,900,1000,1500,3000};
int b=a.length;
String c=br.readLine();
int value=Integer.parseInt(c);
int mid;
int l=0;
int u=a.length-1;
int pos=-1;
while(pos==-1&&u>=l)
{
mid=u+l/2;
if(a[mid]==value)
{
pos=mid;
}
if(a[mid]<value)
{
l=mid+1;
}
if(a[mid]>value)
{
u=mid-1;
}
}
if(pos==-1)
System.out.println("the element is not found");
else
System.out.println("the element is found and it is at "+pos);
}
}