The Java Developers Almanac 1.4


Order this book from Amazon.

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

e362. Inserting an Element into a Sorted List

    int index = Collections.binarySearch(sortedList, object);
    if (index < 0) {
        sortedList.add(-index-1, object);
    }

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

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


© 2002 Addison-Wesley.