Example usage for java.util Vector Vector

List of usage examples for java.util Vector Vector

Introduction

In this page you can find the example usage for java.util Vector Vector.

Prototype

public Vector() 

Source Link

Document

Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.

Usage

From source file:Main.java

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

    v.add("Z");//from  www. j  a  v  a2  s  .  c  om
    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);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Vector v = new Vector();
    v.add("a");//from w  w  w. j  a v  a  2s  .  c o m
    v.add("b");
    v.add("c");

    for (Enumeration e = v.elements(); e.hasMoreElements();) {
        Object o = e.nextElement();
        System.out.println(o);
    }
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Vector v = new Vector();
    v.add("a");/*from   w  w w .  ja  v a 2 s.  c om*/
    v.add("b");
    v.add("c");

    Enumeration e = v.elements();
    while (e.hasMoreElements()) {
        Object o = e.nextElement();
        System.out.println(o);
    }
}

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v1 = new Vector<String>();
    v1.add("1");/*  w w  w. jav  a 2 s  .  c  o m*/
    v1.add("2");
    v1.add("3");

    Vector<String> v2 = new Vector<String>();
    v2.add("One");
    v2.add("Two");
    v2.add("Three");
    v2.add("Four");
    v2.add("Five");

    System.out.println(v2);
    Collections.copy(v2, v1);

    System.out.println(v2);
}

From source file:Main.java

public static void main(String[] args) {
    // create an empty Vector vec   
    Vector<Integer> vec = new Vector<Integer>();

    vec.add(14);//from   w ww  .j  a  va2s .  c  o m
    vec.add(13);
    vec.add(12);
    vec.add(11);
    vec.add(4);
    vec.add(3);
    vec.add(2);
    vec.add(1);

    // let us print the capacity of the vector
    System.out.println("Capacity of the vector is :" + vec.capacity());
}

From source file:MainClass.java

public static void main(String args[]) {

    Vector v = new Vector();

    for (int i = 0; i < 5; i++) {
        v.addElement(new Double(5));
    }/*w  w w  . j a v  a2  s. c  o  m*/

    for (int i = v.size() - 1; i >= 0; i--) {
        System.out.print(v.elementAt(i) + " ");
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Vector data = new Vector();
    new Producer(data).start();
    new Consumer(data).start();
}

From source file:Main.java

public static void main(String args[]) {
    AbstractList<String> v = new Vector<String>();
    v.add("A");/*w w w  .  j  a v a 2s.  c  o  m*/
    v.add("B");

    Iterator i = v.listIterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }
}

From source file:Main.java

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

    v.add("A");//from  w  ww  .  ja  v a2s . c o  m
    v.add("B");
    v.add("D");
    v.add("E");
    v.add("F");

    Enumeration e = Collections.enumeration(v);
    while (e.hasMoreElements())
        System.out.println(e.nextElement());
}

From source file:Main.java

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

    v.add("1");/*from   w  w w .j  a  v a  2  s  . c  om*/
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");

    Comparator comparator = Collections.reverseOrder();
    System.out.println(v);

    Collections.sort(v, comparator);
    System.out.println(v);
}