This week's book giveaway is in the Java 8 forum. We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line! See this thread for details.

You'll need to sort the array first. Binary search by definition works only on sorted arrays. This is because of the way it searches for elements:

1) start at the center 2) check the current element 3) a) if equal then done b) if smaller then all previous elements are smaller; get the binary search of the second half of the array c) if larger then all next elements are larger; get the binary search of the first half of the array

In the end the first / second half of the array will be only one element and the recursion can end. [ November 23, 2008: Message edited by: Rob Prime ]