Monday, October 22, 2012

Vector Demo in Java

Program for vector in java.

Below is the program.

import java.util.*;

class vectorDemo
{
    public static void main(String args[])
    {
        Vector v = new Vector(3,2);

        System.out.println("Intial Size : " + v.size());
        System.out.println("Intial Capacity : " + v.capacity());

        v.addElement(new Integer(1));
        v.addElement(new Integer(2));
        v.addElement(new Integer(3));
        v.addElement(new Integer(4));

        System.out.println("Capacity after 4 additions : " + v.capacity());
        v.addElement(new Double(4.55));
        System.out.println("Capacity after adding double element : " + v.capacity());       
    }
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...