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(Collection<? extends E> c) 

Source Link

Document

Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    Vector v = new Vector(5);
    for (int i = 0; i < 10; i++) {
        v.insertElementAt(i, 0);// www  .ja v  a  2  s .  c  o m
    }
    System.out.println(v);
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v = new Vector(5);
    for (int i = 0; i < 10; i++) {
        v.add(i);//from   w w  w.  ja v a  2 s .c  o m
    }
    System.out.println(v);
}

From source file:Main.java

public static void main(String args[]) {
    Vector v = new Vector(5);
    for (int i = 0; i < 10; i++) {
        v.add(i, 0);/*w w w . j av  a 2 s  . c om*/
    }
    System.out.println(v);

    v.clear();

    System.out.println(v);
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    System.out.println("The vector is empty: " + vec.isEmpty());

    vec.add(4);/*from   w ww.  jav a 2 s  .  c o m*/

    System.out.println("The vector is empty: " + vec.isEmpty());
}

From source file:Main.java

public static void main(String args[]) {
    Vector v = new Vector(5);
    for (int i = 0; i < 10; i++) {
        v.add(0, i);//from  w  w  w .  j a va2 s . c o  m
    }
    System.out.println(v);

    v.setSize(0);

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

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

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

    System.out.println("Size of the vector: " + vec.size());
}

From source file:Main.java

public static void main(String args[]) {
    Vector<Object> v = new Vector<Object>(5);
    for (int i = 0; i < 10; i++) {
        v.add(0, i);//from   w  ww  .  ja  v  a 2s  .c  o  m
    }
    System.out.println(v);
    v.setSize(3);
    System.out.println(v);
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

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

    // let us get the hashcode of the vector
    System.out.println("Hash code :" + vec.hashCode());
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

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

    // let us get the index of 3
    System.out.println("Index of 3 is :" + vec.indexOf(3));
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

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

    // let us print the last element of the vector
    System.out.println("Last element: " + vec.lastElement());
}