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 vec = new Vector(5);
        for (int i = 0; i < 10; i++) {
            vec.add(0, i);
        }
        System.out.println("Content of the vector: " + vec);
        System.out.println("Size of the vector: " + vec.size());

        // ensure the capacity of the vector and add elements
        vec.ensureCapacity(40);
        for (int i = 0; i < 10; i++) {
            vec.add(0, i);
        }
        System.out.println(vec);
        System.out.println(vec.size());
    }
}