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) {
    System.out.println(new Vector().getClass().getPackage().getName());
    System.out.println(new ArrayList().getClass().getPackage().getName());
    System.out.println("Test String".getClass().getPackage().getName());
    System.out.println(new Integer(1).getClass().getPackage().getName());
}

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");/*from w w  w . j  a v  a2s .c om*/
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    for (int i = 0; i < l.size(); i++) {
        System.out.println(l.get(i));
    }
}

From source file:Main.java

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

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

From source file:SafeVectorCopy.java

public static void main(String[] args) {
    Vector vect = new Vector();
    vect.addElement("Synchronization");
    vect.addElement("is");
    vect.addElement("important");

    String[] word;//  w ww.  ja v a  2s  .  c  o m

    synchronized (vect) {
        int size = vect.size();
        word = new String[size];

        for (int i = 0; i < word.length; i++) {
            word[i] = (String) vect.elementAt(i);
        }
    }

    System.out.println("word.length" + word.length);
    for (int i = 0; i < word.length; i++) {
        System.out.println("[" + i + "]=" + word[i]);
    }
}

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");//from  w w  w  .  j  ava  2  s  . com
    v1.add("B");
    v1.add("C");
    List l = v1.subList(1, 2);

    l.remove(0);

    System.out.println(l);
    System.out.println(v1);
}

From source file:Main.java

public static void main(String[] args) {
    Vector<Double> v = new Vector<Double>();
    v.add(new Double("3.4"));
    v.add(new Double("3.3"));
    v.add(new Double("4.4"));
    v.add(new Double("5.3"));
    v.add(new Double("3.3"));
    Object obj = Collections.min(v);
    System.out.println(obj);//  w ww  . java2s .  co m
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v1 = new Vector();
    v1.add("A");// ww  w  . j  a v  a2 s .c om
    v1.add("C");
    v1.add("B");
    Vector v2 = (Vector) v1.clone();
    Collections.sort(v2);

    System.out.println(v1);
    System.out.println(v2);
}

From source file:MainClass.java

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

    Enumeration e = v.elements();
    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("A");/*from   ww  w. j a v  a2  s . c om*/
    v.add("B");
    v.add("A");
    v.add("C");
    v.add("D");

    System.out.println(v);
    Collections.replaceAll(v, "A", "Replace All");
    System.out.println(v);
}

From source file:Main.java

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

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

    System.out.println(v);
    Collections.swap(v, 0, 4);
    System.out.println(v);
}