Java examples for Collection Framework:Vector
Perform Binary Search on Vector
import java.util.Vector; import java.util.Collections; public class Main { public static void main(String[] args) { Vector v = new Vector(); v.add("A");//from www . j a va2 s. co m v.add("B"); v.add("D"); v.add("E"); v.add("F"); Collections.sort(v); System.out.println("Sorted Vector contains : " + v); int index = Collections.binarySearch(v,"D"); System.out.println("Element found at : " + index); } }