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<String> v = new Vector<String>();
    v.add("1");
    v.add("3");/*from w  w  w.j  ava  2  s . c  o  m*/
    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");
    v.add("B");//from   w  w w. j a  v a  2s . c  om

    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");
  v.add("2");/*  www .j  a v a 2 s  .  c  o  m*/
  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<Integer> vec = new Vector<Integer>(4);

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

    System.out.println(vec);

}

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 w  w .j av a 2  s  .  c  om
}

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  ww  .  j  a  v  a 2s .c  o m*/
    vec.add(2);
    vec.add(1);

    // let us check the first element of the vector
    System.out.println("First element is :" + vec.firstElement());
}

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 w  w  .j  a v  a 2  s .c  om
    v.add("D");
    v.add("E");
    v.add("F");

    Enumeration e = Collections.enumeration(v);
    while (e.hasMoreElements())
        System.out.println(e.nextElement());
}

From source file:Main.java

public static void main(String[] args) {

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

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

    // let us check the existence of number 4 in the vector
    System.out.println(vec.contains(4));
}

From source file:Main.java

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

    System.out.println(v);
    Enumeration<String> e = v.elements();

    ArrayList<String> aList = Collections.list(e);
    System.out.println(aList);
}

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");// w  w  w  . ja v a  2 s .  co m
    v.add("java2s.com");

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

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