The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.util  [50 examples] > Sorted Collections  [5 examples]

e360. Finding an Element in a Sorted Array

This example also works if the object is a primitive type.
    int index = Arrays.binarySearch(sortedArray, object);
    if (index < 0) {
        // not found
    }

 Related Examples
e358. Creating a Sorted Set
e359. Sorting an Array
e361. Finding an Element in a Sorted List
e362. Inserting an Element into a Sorted List

See also: Arrays    Bits    Collections    Dates    Hash Tables    Lists    Property Files    Sets    Time    Timers   


© 2002 Addison-Wesley.