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) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);//from  www. j a va 2 s .c om
    vec.add(2);
    vec.add(1);

    // convert the contents into string
    System.out.println(vec.toString());

}

From source file:MainClass.java

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

    Collection col = v;
    Enumeration 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 vec = new Vector(6);

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

    // let us print the last index of 1
    System.out.println("last index :" + vec.lastIndexOf(1));
}

From source file:Main.java

public static void main(String[] args) {

    Collection<Integer> list = new ArrayList<Integer>();
    list.add(9);/* w  w  w  . j  av a 2s . c  o m*/
    Vector vec = new Vector(list);

    vec.add(4);
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println(vec);
}

From source file:Main.java

public static void main(String[] args) {

    Vector v = new Vector();

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

    Collections.sort(v);

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

}

From source file:MainClass.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("A");
    v.add("B");//from   www .j  a  v a2s. co m
    String firstElement = (String) v.firstElement();
    String lastElement = (String) v.lastElement();

    System.out.println(firstElement);
    System.out.println(lastElement);
}

From source file:Main.java

public static void main(String[] args) {
    // create an empty Vector vec with an initial capacity of 6     
    Vector vec = new Vector(6);

    vec.add(33);
    vec.add(34);//from w w  w.  j  ava2  s .co m
    vec.add(22);
    vec.add(11);
    vec.add(22);
    vec.add(12);

    // let us remove the 1st element
    System.out.println("Removed element: " + vec.remove((Integer) 22));

    System.out.println(vec);
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);/*from  www  .j  a  v  a  2 s.c  o  m*/
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

    // let us insert element at 1st position
    vec.insertElementAt(133, 1);

    System.out.println(vec);
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);//ww w .j ava2 s .  c  o  m
    vec.add(2);
    vec.add(3);
    vec.add(2);
    vec.add(3);

    /** let us get the index of 3
     * starting search from 2nd index
     */
    System.out.println("Index of 3 :" + vec.indexOf(3, 2));
}

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);//from  www .j  ava2 s .co m
}