Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Vector;

public class Main {
    public static void main(String[] args) {
        Vector<Integer> firstvec = new Vector<Integer>(4);
        Vector<Integer> secondvec = new Vector<Integer>(4);

        // use add() method to add elements in the secondvec vector
        secondvec.add(5);
        secondvec.add(6);
        secondvec.add(7);
        secondvec.add(8);

        // use add() method to add elements in the firstvec vector
        firstvec.add(1);
        firstvec.add(2);
        firstvec.add(3);
        firstvec.add(4);

        /** use addAll() method to add elements of the 2nd vector at 
        1st element position of the first vector */

        firstvec.addAll(1, secondvec);

        System.out.println(firstvec);

    }
}