-3
public static void main(String[] args){

}
public final static int NOT_FOUND = -1;
public int binarySearch (int[] number, int searchValue){

    int     low = 0,
            high = number.length - 1,
            mid = (low + high) / 2;
    while(low <= high && number[mid] != searchValue){
        if(number[mid] < searchValue){
            low = mid + 1;
        } else {
            high = mid -1;
        }
        mid = (low + high) / 2;
    }
    if(low > high){
        mid = NOT_FOUND;
    }
    return mid;       
}
}

I made a binary search but it didn't run. what is the problem in the codes? There is no error but when I run it theres nothing.

Rex
  • 5
  • 2

1 Answers1

0

You didn't call a binary search in your main.

DarkJade
  • 270
  • 1
  • 8
  • Use the method you created and pass in your array public static void main(String[] args){binarySearch(arrayOfNumbers, valueYou'reLookingFor);} – DarkJade Mar 08 '16 at 22:36
  • but how? i didnt get it. im just a beginner in programming. – Rex Mar 08 '16 at 22:51
  • like this?public static void main(String[] args){ binarySearch(arrayOfNumbers, valueYou'reLookingFor); } public final static int NOT_FOUND = -1; public int binarySearch (int[] number, int searchValue){ – Rex Mar 08 '16 at 22:51