programming-examples/java/Data_Structures/How to execute binary search on a vector.java
2019-11-15 12:59:38 +01:00

16 lines
446 B
Java

import java.util.Collections;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Vector v = new Vector();
v.add("X");
v.add("M");
v.add("D");
v.add("A");
v.add("O");
Collections.sort(v);
System.out.println(v);
int index = Collections.binarySearch(v, "D");
System.out.println("Element found at : " + index);
}
}