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:MainClass.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("A");/*ww  w  .  j a  v a2 s. co m*/
    v.add("B");
    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[]) {
    Vector<String> v1 = new Vector<String>();
    v1.add("A");/*from  w w  w  .j a va 2  s .  com*/
    v1.add("B");
    v1.add("C");
    String array[] = new String[0];
    array = (String[]) v1.toArray(array);

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

From source file:MainClass.java

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

    Vector v2 = new Vector();
    v2.add("A");
    v2.add("B");
    v2.add("C");

    boolean isContaining = v2.containsAll(v);

    System.out.println(isContaining);
}

From source file:Main.java

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

    System.out.println(v.indexOf("1", 4));
    System.out.println(v.lastIndexOf("2", 5));
}

From source file:Main.java

public static void main(String[] args) {

    Vector<Integer> vec = new Vector<Integer>();

    vec.add(4);//from w  ww.ja  va  2  s  . c o  m
    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<String> v = new Vector<String>();
    v.add("A");//from   ww w .  java2  s  .c  o  m
    v.add("B");

    Vector<String> v2 = new Vector<String>();
    v2.add("A");
    v2.add("B");
    v2.add("C");

    boolean isContaining = v2.containsAll(v);

    System.out.println(isContaining);
}

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 va2  s  .  com
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");
    v.add("1");
    v.add("2");

    System.out.println(v.contains("3"));
    System.out.println(v.indexOf("5"));
    System.out.println(v.lastIndexOf("2"));
}

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 a2s  .  c om
    v.add("2");
    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) {
    Vector<String> v = new Vector<String>();

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

    v.setSize(3);

    for (String str : v) {
        System.out.println(str);
    }
    v.setSize(5);
    for (String str : v) {
        System.out.println(str);
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Vector v1 = new Vector();
    v1.add("A");/*ww  w  .j a  v a 2s .  co m*/
    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));
    }
}