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) {
    Vector<String> v = new Vector<String>();

    v.add("A");/*from  w ww .  ja  va  2s .  co m*/
    v.add("B");
    v.add("D");

    System.out.println(v);
    Collections.fill(v, "REPLACED");
    System.out.println(v);
}

From source file:Main.java

public static void main(String[] args) {

    Vector v = new Vector();

    v.add("1");//from   www  .ja v  a2 s. co m
    v.add("3");
    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:Main.java

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

    Collections.sort(v);

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

From source file:Main.java

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

    v.add("A");//from w  w  w .jav a2s  . co m
    v.add("B");
    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<Integer> vec = new Vector<Integer>();

    vec.add(4);//from  w w  w .java  2  s .  c  o m
    vec.add(3);
    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<Double> v = new Vector<Double>();

    v.add(new Double("3.4324"));
    v.add(new Double("3.3532"));
    v.add(new Double("3.342"));
    v.add(new Double("3.349"));
    v.add(new Double("2.3"));

    Object obj = Collections.max(v);
    System.out.println(obj);/*from w  ww . j a  va  2s  .  com*/
}

From source file:Main.java

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

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

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

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v = new Vector<String>();
    v.add("1");/*w  w  w . j  ava 2 s  .co m*/
    v.add("2");
    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<Integer> vec = new Vector<Integer>();

    vec.add(4);//from www .jav  a2  s.  c  o m
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

    ListIterator<Integer> it = vec.listIterator(2);
    while (it.hasNext()) {
        System.out.println(it.next());
    }
}

From source file:Main.java

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

    v.add("1");//  www . ja v a 2  s.  com
    v.add("2");
    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());
    }
}