import java.util.Arrays;
public class BinarySearch
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
int array[]={1,3,4,7,6,23};
int p,key=6;
p=Arrays.binarySearch(array, key);
System.out.println("element found"+p);
Arrays.sort(array);
p=Arrays.binarySearch(array, key);
System.out.println("element found"+p);
}
}
No comments:
Post a Comment