Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

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

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    Vector<String> v = new Vector<String>();
    v.add("a");
    v.add("b");//from   ww  w. ja  va2s.  co  m
    v.add("c");

    Collection<String> col = v;
    Enumeration<String> e = Collections.enumeration(col);

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

From source file:Main.java

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

    v.add("A");
    v.add("B");/*from w  ww .  j av  a  2s  .c  o  m*/
    v.add("C");
    v.add("D");
    v.add("E");

    System.out.println(v);
    Collections.reverse(v);
    System.out.println(v);
}

From source file:Main.java

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

    v.add("1");
    v.add("2");/*from w ww  .  j a  v a2 s .  com*/
    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);
}

From source file:Main.java

public static void main(String[] args) {

    Vector<String> v = new Vector<String>();

    v.add("1");
    v.add("2");// ww  w . j av a 2  s  .c  om
    v.add("3");

    System.out.println(v.size());

    v.clear();

    v.removeAllElements();

    System.out.println(v.size());
}

From source file:Main.java

public static void main(String[] args) {
    List<String> arrayList = new ArrayList<String>();
    arrayList.add("1");
    arrayList.add("2");
    arrayList.add("3");

    Vector<String> v = new Vector<String>();
    v.add("4");
    v.add("5");/*from   ww w . ja v a 2s. com*/

    // insert all elements of Vector to ArrayList at index 1
    arrayList.addAll(1, v);

    for (String str : arrayList)
        System.out.println(str);
}

From source file:Main.java

public static void main(String[] args) {

    Vector<Integer> vec = new Vector<Integer>(40, 10);

    vec.add(4);
    vec.add(3);//  w w  w.  j  a v  a 2  s  . co  m
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

}

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v = new Vector<String>();
    v.add("1");
    v.add("2");/*from   ww w .j  a  va 2  s .  c om*/
    v.add("3");

    ArrayList<String> arrayList = new ArrayList<String>();
    arrayList.add("4");
    arrayList.add("5");

    v.addAll(arrayList);

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

From source file:Main.java

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

    v.add("1");
    v.add("2");//from  w w  w  .j av a2s. c  o  m
    v.add("3");
    v.add("4");
    v.add("5");

    ListIterator itr = v.listIterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    while (itr.hasPrevious()) {
        System.out.println(itr.previous());
    }
}

From source file:Main.java

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

    vec.add(4);
    vec.add(3);/*ww w . j  av  a 2s .c o m*/
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

    Iterator<Integer> it = vec.iterator();
    while (it.hasNext()) {
        System.out.println(it.next());
    }
}

From source file:Main.java

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

    vec.add(4);
    vec.add(3);//from   w w w .j ava2  s  . co m
    vec.add(2);
    vec.add(1);

    // set new size to 8
    vec.setSize(8);

    for (Integer number : vec) {
        System.out.println("Number = " + number);
    }
}