Finding an Element in a Sorted Array
import java.util.Arrays;
public class Main {
public static void main(String[] argv) {
String[] sortedArray = new String[] { "a", "b", "c", "d" };
int index = Arrays.binarySearch(sortedArray, "c");
index = Arrays.binarySearch(sortedArray, "e");
int[] sortedIntArray = new int[] { 1, 2, 3, 5, 7 };
index = Arrays.binarySearch(sortedIntArray, 6);
}
}
Related examples in the same category