Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Collections;
import java.util.Vector;

public class Main {

    public static void main(String[] args) {
        Vector<String> v = new Vector<String>();

        v.add("Z");
        v.add("B");
        v.add("D");
        v.add("E");
        v.add("F");

        Collections.sort(v);
        System.out.println(v);

        int index = Collections.binarySearch(v, "D");
        System.out.println("Element found at : " + index);
    }
}
/*[B, D, E, F, Z]
Element found at : 1
*/