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  w ww  .j  av a 2 s .c om*/
    vec.add(2);
    vec.add(1);

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

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    String alg = "DSA";
    KeyPairGenerator kg = KeyPairGenerator.getInstance(alg);
    KeyPair keyPair = kg.genKeyPair();

    Vector v = new Vector();
    v.add("This is a test!");
    Signature sign = Signature.getInstance(alg);
    SignedObject so = new SignedObject(v, keyPair.getPrivate(), sign);
    System.out.println(so.verify(keyPair.getPublic(), sign));
}

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);//from   w  ww. j a  v  a  2 s .c  om
    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);
    vec.add(3);//  ww w  .  ja  v a2s  . c  o  m
    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);
    vec.add(3);//from  www .ja  va  2 s.  c o m
    vec.add(2);
    vec.add(1);

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

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);//  w w w  . j av  a2s. c  o m
    vec.add(2);
    vec.add(1);

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

From source file:Main.java

public static void main(String[] args) {

    Vector vec = new Vector(4);

    vec.add(4);
    vec.add(3);/*from   w  w w .  java  2 s .  co  m*/
    vec.add(2);
    vec.add(1);

    // let us get the 3rd element of the vector
    System.out.println("Third element is :" + vec.get(3));
}

From source file:MainClass.java

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

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

    vec.add(6);
    vec.add(5);// ww w . jav  a2  s  .  co m
    vec.add(4);
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println("index is: " + vec.lastIndexOf(1, 4));
}

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("Hello");
    v.add("Hello");
    String s = v.get(0);//from   w  w  w  .  j av a2 s. c  o m
    System.out.println(s);
}