Java tutorial
import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String args[]) { // create arraylist ArrayList<String> arlst = new ArrayList<String>(); arlst.add("A"); arlst.add("B"); arlst.add("C"); arlst.add("D"); // search for key int index = Collections.binarySearch(arlst, "D", Collections.reverseOrder()); System.out.println(index); index = Collections.binarySearch(arlst, "D"); System.out.println(index); } }